Subject: Re: bug#69249: bug in native-compile?

From: Robert Boyer <[email-masked]>
Date: Sun, 18 Feb 2024 16:19:49 -0600

This message is about how important DECLARE and THE are.  If you do not
handle DECLARE and THE right, people will laugh at native-compile.

Here is an SBCL transcript.  I am running on a $100 Lenovo Chromebook.

I got SBCL with the command sudo apt-get install sbcl.

* (declaim (optimize (safety 0) (speed 3) (debug 0)))
NIL
* (defun foo-with-declare (n)
  (let ((i 0)
        (sum 0)
        (max (expt 10 n)))
    (declare (fixnum i sum max))
    (loop (cond ((<= i max)
                 (setq sum (the fixnum (+ sum i))))
                (t (return sum)))
          (incf i))))
FOO-WITH-DECLARE
* (time (foo-with-declare 8))
Evaluation took:
  0.125 seconds of real time
  0.123203 seconds of total run time (0.123193 user, 0.000010 system)
  98.40% CPU
  135,905,516 processor cycles
  0 bytes consed
5000000050000000
* (defun foo-without-declare (n)
  (let ((i 0)
        (sum 0)
        (max (expt 10 n)))
    (loop (cond ((<= i max)
                 (setq sum (+ sum i)))
                (t (return sum)))
          (incf i))))
WARNING: redefining COMMON-LISP-USER::FOO-WITHOUT-DECLARE in DEFUN
FOO-WITHOUT-DECLARE
* (time (foo-without-declare 8))
Evaluation took:
  1.080 seconds of real time
  1.072932 seconds of total run time (1.072932 user, 0.000000 system)
  99.35% CPU
  1,181,369,303 processor cycles
  0 bytes consed
5000000050000000

People go wow about 8X.  How does native-compile do?

There is a great song by Alabama 'If you gonna play in Texas, you gotta
have a fiddle in the band'. Check it out!

https://www.youtube.com/watch?v=w6r4E514nJg

Bob

Bob

On Sun, Feb 18, 2024 at 3:28 PM Andreas Schwab <[email-masked]>
wrote:

> On Feb 18 2024, Robert Boyer wrote:
>
> > Furthermore, such declare forms are necessary for life as we know it
> > in the free world, so that fixnum arithmetic can be used where
> > appropriate!
>
> If you are programming in Emacs Lisp, you need to follow the rules of
> Emacs Lisp.
>
> --
> Andreas Schwab, [email-masked]
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."
>

-- 
Anything I seem to state should be taken as a question.  I am at least 77
and feeble.