From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Robert Boyer Newsgroups: gmane.emacs.bugs Subject: bug#69249: bug in native-compile? Date: Sun, 18 Feb 2024 16:39:25 -0600 Message-ID: References: <86h6i5r20h.fsf@gnu.org> <8734tp5uoq.fsf@igel.home> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000070ebd70611afa81d" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="3380"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69249@debbugs.gnu.org, Eli Zaretskii , Andrea Corallo , Stefan Monnier , rms@gnu.org To: Andreas Schwab Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 19 04:20:13 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane-mx.org Original-Received: from lists.gnu.org ([209.51.188.17]) by ciao.gmane.io with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1rbuCT-0000hS-Bs for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Feb 2024 04:20:13 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbuC0-0003SE-2Z; Sun, 18 Feb 2024 22:19:44 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rbuBy-0003Qv-8y for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 22:19:42 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rbuBy-0007Yz-0x for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 22:19:42 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rbuCI-0008L6-RK for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 22:20:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Robert Boyer Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 19 Feb 2024 03:20:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 69249 X-GNU-PR-Package: emacs Original-Received: via spool by 69249-submit@debbugs.gnu.org id=B69249.170831277131984 (code B ref 69249); Mon, 19 Feb 2024 03:20:02 +0000 Original-Received: (at 69249) by debbugs.gnu.org; 19 Feb 2024 03:19:31 +0000 Original-Received: from localhost ([127.0.0.1]:40086 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbuBm-0008Jg-BE for submit@debbugs.gnu.org; Sun, 18 Feb 2024 22:19:31 -0500 Original-Received: from mail-ej1-f44.google.com ([209.85.218.44]:58804) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbpqj-0000rn-VQ for 69249@debbugs.gnu.org; Sun, 18 Feb 2024 17:41:31 -0500 Original-Received: by mail-ej1-f44.google.com with SMTP id a640c23a62f3a-a293f2280c7so510346166b.1 for <69249@debbugs.gnu.org>; Sun, 18 Feb 2024 14:41:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708296003; x=1708900803; darn=debbugs.gnu.org; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KM0t2xwF00gYvLHb1oKUrdqKpfoIEkAt83PwUon7KNg=; b=Lg/bu6hOC/nKevFLmetiDMlBCut/tpz4U+wOUC/I+yyef+IgEjDnHnIsa43mzj6dAL YZsiSZp2DtJPTpBVme+pMpRJYz5apxWb+JUc4qEd6smbMoSuy/gW1WEjfZOG3RcGOLhu NEv3uTKnK2SBg+EqFIEEKXhMoPb/VzD7f8s+4JpefgzKWAZ6SOQkARDGSAArlDWsaKNJ HULYQYDsFosXTWch/ipco/5WGmjeHoB7JoJ/hF5HaIHVA/SbMd3DNT3Bg1Z2dRbwgntH ACOEvNzOdilGFfI6iaHsMiQwyt7L+RGtyY9rHMVEucFRli5whmk2VPCO09GdLrxuB3au bD6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708296003; x=1708900803; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KM0t2xwF00gYvLHb1oKUrdqKpfoIEkAt83PwUon7KNg=; b=Ngs8DWWGFyMJWj0ykziCvqeL84S78DHGR/LTLYWhrlD3abv9uFw2vQAZ5nlUAVO1/H mLLSQfcrv/hqb2hyd/YZECHPv2ivlyaEtVEVtvzSs+WvjQ7t0+XYA7xWrlD9fMQND7yK NuMjlnUEhousYMO1Tex6LYn2NtwnRrm2rXCn/sJpKuUVUW+Ab/1J+Sejn6aqE+OaMcVF eZbwu39NdNe6qPrPuU8O++bSC77qk2SmjG9xTNC+fLBbS9damrXEFuhYBtorI52dd802 C2ItorBZcq8UoA/49D5vAxDnXF04Aj3EZJTp3twjKdtcbgVe8PL2ZLTtz7aSgmpsg4ch VDqw== X-Forwarded-Encrypted: i=1; AJvYcCVp4fgPk04stz54GD+puTsuVXsmKMCnzMb8ljZpvXGwtbrZf1/XDhuoWFElsbObD+k9jFtws8RcGuamenF0o4ajYfueXfs= X-Gm-Message-State: AOJu0YyP3G/d05W2Haj6BZuGLsOerYcdont+pew7z84S2mWWFs0ApyiK Wd2nC6FivRQAwUAc+NslBikLt86wmpLa7Lv6mB1ntScFm/1IHxwDWtJl23Avl7eMWKN9t0c5xRB WxNUd7ZED+c18at5L6Btl+Zks2ws= X-Google-Smtp-Source: AGHT+IFlm5rg7KLfzV9FP/EaArozt2aVFy3tNpP3ZQwoqq2+HLl2DX8JunR6JfwAEvyVhM3bjW6J4myJCWP4tVPFA8I= X-Received: by 2002:a17:906:288b:b0:a3e:8333:d0b2 with SMTP id o11-20020a170906288b00b00a3e8333d0b2mr881755ejd.23.1708296003184; Sun, 18 Feb 2024 14:40:03 -0800 (PST) In-Reply-To: X-Mailman-Approved-At: Sun, 18 Feb 2024 22:19:27 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:280226 Archived-At: --00000000000070ebd70611afa81d Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Look out, here it comes, as Tracy Schwarz says. The following DISASSEMBLE might tell you what you need to do for native-compile. Speaking with the utmost sincerity, I know less about the following than I do about what Proust called the greatest painting in the world, the View of Delft by Vermmer. Check it out. https://www.mauritshuis.nl/en/our-collection/artworks/92-view-of-delft/ Again, this is in SBCL on my $100 Lenovo Chromebook. * (disassemble 'foo-with-declare) ; disassembly for FOO-WITH-DECLARE ; Size: 60 bytes. Origin: #x52A4AF19 ; FOO-WITH-DECLARE ; 19: 4883EC10 SUB RSP, 16 ; 1D: BA14000000 MOV EDX, 20 ; 22: B904000000 MOV ECX, 4 ; 27: 48892C24 MOV [RSP], RBP ; 2B: 488BEC MOV RBP, RSP ; 2E: B842BD3550 MOV EAX, #x5035BD42 ; # ; 33: FFD0 CALL RAX ; 35: 31C0 XOR EAX, EAX ; 37: 31C9 XOR ECX, ECX ; 39: EB0C JMP L1 ; 3B: 0F1F440000 NOP ; 40: L0: 4801C1 ADD RCX, RAX ; 43: 4883C002 ADD RAX, 2 ; 47: L1: 4839D0 CMP RAX, RDX ; 4A: 7EF4 JLE L0 ; 4C: 488BD1 MOV RDX, RCX ; 4F: 488BE5 MOV RSP, RBP ; 52: F8 CLC ; 53: 5D POP RBP ; 54: C3 RET NIL * Bob On Sun, Feb 18, 2024 at 4:25=E2=80=AFPM Robert Boyer wrote: > And you should know what DECLARE and THE do for AREF. All the difference > in the world, and I will give you a simple demo if you wish. > > Bob > > On Sun, Feb 18, 2024 at 4:19=E2=80=AFPM Robert Boyer > wrote: > >> 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 ((<=3D 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 ((<=3D 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=3Dw6r4E514nJg >> >> Bob >> >> >> Bob >> >> >> On Sun, Feb 18, 2024 at 3:28=E2=80=AFPM Andreas Schwab >> 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, schwab@linux-m68k.org >>> GPG Key fingerprint =3D 7578 EB47 D4E5 4D69 2510 2552 DF73 E780 A9DA A= EC1 >>> "And now for something completely different." >>> >> >> >> -- >> Anything I seem to state should be taken as a question. I am at least 7= 7 >> and feeble. >> > > > -- > Anything I seem to state should be taken as a question. I am at least 77 > and feeble. > --=20 Anything I seem to state should be taken as a question. I am at least 77 and feeble. --00000000000070ebd70611afa81d Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Look out, here i= t comes, as Tracy Schwarz says.

The=C2=A0following DISASSEMBLE migh= t tell you what you need to do for native-compile.=C2=A0
<= span style=3D"font-family:monospace">
Speaking with the utmost sincerity, I know less about= the following than I do about what=C2=A0Proust called the greatest paintin= g in the world, the View of Delft=C2=A0by Vermmer.=C2=A0 Check it out.

Again, this is in SBCL on my $100 Lenovo Chromebook.

* (disassemble 'foo-with-declare)
; disassembly for FOO-WITH-DE= CLARE
; Size: 60 bytes. Origin: #x52A4AF19 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0; FOO-WITH-DE= CLARE
; 19: =C2=A0 =C2=A0 =C2=A0 4883EC10 =C2=A0 =C2=A0 =C2=A0 =C2=A0 SU= B RSP, 16
; 1D: =C2=A0 =C2=A0 =C2=A0 BA14000000 =C2=A0 =C2=A0 =C2=A0 MOV= EDX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 =C2=A0 488BD1 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 MOV RDX, RCX
; 4F: =C2=A0 =C2=A0 =C2=A0 488BE5 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 MOV RSP, RBP
; 52: =C2=A0 =C2=A0 =C2=A0 F8 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 CLC
; 53: =C2=A0 =C2=A0 =C2=A0 5D= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 POP RBP
; 54: =C2=A0 = =C2=A0 =C2=A0 C3 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 RET
NI= L
*=C2=A0

Bob


On Sun, Feb 18, 2024 at 4:25=E2=80=AFPM Robert Boyer <robertstephenboyer@gmail.com> w= rote:
And you should know what DECLARE and= THE do for AREF.=C2=A0 All the difference in the world, and I will give yo= u a simple demo if you wish.

Bob

On Sun, Feb 18, 2024 at 4:19=E2=80=AFPM = Robert Boyer <robertstephenboyer@gmail.com> wrote:
This message is about how important DECLARE= and THE are.=C2=A0 If you do not
handle DECLARE and THE right, people will laugh=C2=A0at native-compile.

Here is=C2=A0an SBCL transcript.=C2=A0 I am running on a $100 L= enovo Chromebook.

I got SBCL with the command=C2=A0sudo apt-g= et install sbcl.

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

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

There is a great song by Alabama 'If you gonna=C2=A0play in Te= xas, you gotta have a fiddle in the band'. Check it out!


Bob=


Bob


On Sun, Feb 18, 2024 at 3:28=E2=80=AFPM Andreas Schwab &= lt;schwab@linux-= m68k.org> 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, = schwab@linux-m68k.org
GPG Key fingerprint =3D 7578 EB47 D4E5 4D69 2510=C2=A0 2552 DF73 E780 A9DA = AEC1
"And now for something completely different."


--
Anythin= g I seem to state should be taken as a question.=C2=A0 I am at least 77 and= feeble.

<= font face=3D"monospace">
--
Anything I s= eem to state should be taken as a question.=C2=A0 I am at least 77 and feeb= le.

<= font face=3D"monospace">
--
Anything I s= eem to state should be taken as a question.=C2=A0 I am at least 77 and feeb= le.
--00000000000070ebd70611afa81d--