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 17:42:03 -0600 Message-ID: References: Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000072bfb80611b088e2" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="4729"; mail-complaints-to="usenet@ciao.gmane.io" Cc: 69249@debbugs.gnu.org, rms@gnu.org To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 19 04:20:31 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 1rbuCl-000132-6C for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 19 Feb 2024 04:20:31 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rbuC0-0003SY-Tm; 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-0003R5-N0 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-0007ZS-Ea 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 1rbuCJ-0008LE-8O for bug-gnu-emacs@gnu.org; Sun, 18 Feb 2024 22:20:03 -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:03 +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.170831277231992 (code B ref 69249); Mon, 19 Feb 2024 03:20:03 +0000 Original-Received: (at 69249) by debbugs.gnu.org; 19 Feb 2024 03:19:32 +0000 Original-Received: from localhost ([127.0.0.1]:40088 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbuBn-0008Jp-I4 for submit@debbugs.gnu.org; Sun, 18 Feb 2024 22:19:32 -0500 Original-Received: from mail-ed1-f52.google.com ([209.85.208.52]:46590) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rbqpM-0002fK-8H for 69249@debbugs.gnu.org; Sun, 18 Feb 2024 18:44:10 -0500 Original-Received: by mail-ed1-f52.google.com with SMTP id 4fb4d7f45d1cf-563c2b2bddbso4742189a12.1 for <69249@debbugs.gnu.org>; Sun, 18 Feb 2024 15:43:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708299762; x=1708904562; 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=EvIRmmeqqk9WNurcNPeA/9bEel8hRcHvVUzmqFUq5NE=; b=P9hm/xRy4U8kkPDXcyxR+7HYLnMuhO3E1cpdhjqr14NsUpKOpb0zD8G0LAd0a/DF4M n0C5sTc3i/VepaokWkExHxRjhtUDMRJb9i66umsK6clr10LoQg1aJgE69Mfk1xaRXsqb VkOwiYI4vxGGBjrPtClVtSxlr1ChiuY+ivSvrcFw8uuDYUoau4dcs11u1DsOzzuklLAR 3er+Vptrxp24fHZ8MJsHSiR5Unecq8UZ8+t056jrpFoJcNBUZaIzlZKQOVsA+2E1xlFG imkhAZdFeRO0PlZ1i08U1gKU6GcbOLGVml+PYPT8bsgqp7shqWDm6c8z60L/jzjaX5vH ylhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708299762; x=1708904562; 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=EvIRmmeqqk9WNurcNPeA/9bEel8hRcHvVUzmqFUq5NE=; b=h/SH1PtXzg4lSp+jYomjomDQ4RNquvLukvGnfAtCvzbg360+r1czt/kzKAVzeq6wTD ekhlsqhUc8PTDcwTD2bQk4JeT6T+JUWCqR64N8kmSNS8oxI178zeECjGp5a6Sxuf5Gq4 g/d9s8F1sxBlLiKfkfFRbalHSvrLcs3/unSa1IaO+fbvN+jVZ12V+VgPxcsBFX2L7RZ6 +dmla07RWUDgxZYvMQmDAm5qCmyCQHxR+5ZpjjldLNeVgFf1a8l8iEa0uDSDm9Faj5W/ mDeIcYSldX4wf43K03vJelNwostffPw1jO1ai3qxWpDzaM+bfbt2B6taZV0CKtsiNlPK A0DQ== X-Gm-Message-State: AOJu0Ywielt+fSWfpt5aaxeUtDUK9Skkg7O6smbN4CvwVYRqAB/bMzCS PDJ+slmXbZ1L1VX3YqUERYaP5EgT5PFAaWGgvTdW5qmnHUiQ8xuqlWZjpKhHXTF/35Rn2bbhj23 dQyM7PxDomcC6g47PB9VqBY89UHY= X-Google-Smtp-Source: AGHT+IF+i7kDlOJva0qdCgmiV0v9m69PdVocsh7HLiMbkBnkL40cT7Tb2tKvFWtwhrP5rqrOf8Xs4MiR5OocCfiDwoQ= X-Received: by 2002:aa7:c75a:0:b0:564:1de6:c8c0 with SMTP id c26-20020aa7c75a000000b005641de6c8c0mr2973645eds.31.1708299761400; Sun, 18 Feb 2024 15:42:41 -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:280229 Archived-At: --00000000000072bfb80611b088e2 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable If so, we'd be interested to see your code to try and improve our compiler= . I hope this helps. If not, please let me know. Robert Boyer 4:19=E2=80=AFPM (1 hour ago) Reply to all to Andreas, Eli, 69249, Andrea, Stefan, rms 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 AEC= 1 > "And now for something completely different." > -- Anything I seem to state should be taken as a question. I am at least 77 and feeble. Attachments area Preview YouTube video If You're Gonna Play In Texas If You're Gonna Play In Texas Reply allReplyForward Add reaction On Sun, Feb 18, 2024 at 5:32=E2=80=AFPM Stefan Monnier wrote: > > ;; However, (native-compile "compile-bug.el") results in the following > > error message: > > > > ;; Compiling file > > /mnt/chromeos/GoogleDrive/MyDrive/Linux/working/compile-bug.el at Fri F= eb > > 16 08:25:19 2024 > > ;; compile-bug.el:2:45: Warning: Unknown defun property =E2=80=98fixnum= =E2=80=99 in foo > > ;; compile-bug.el:2:45: Warning: Unknown defun property =E2=80=98vector= =E2=80=99 in foo > > First thing: these are not error messages! They're *warnings*! > > `batch-byte-compile` also gives those warnings, because ELisp does not > know those declarations. The native compiler does support some type > annotations, but they do not take this shape. > > I presume you took those from some other Lisp dialect, but that won't do > you much good. Scheme is not Clojure is not Common Lisp is not ELisp ... > > BTW, A more recent Emacs would give you an additional warning: > > Warning: file has no =E2=80=98lexical-binding=E2=80=99 directive on i= ts first line > > So, I see no bug. Did the resulting native-compile misbehave in > any way? I presume you're worried about its performance. > If so, do you have concrete code where you measured the performance and > were disappointed and where you have good reasons to believe that type > annotations would make a difference? If so, we'd be interested to see > your code to try and improve our compiler. > > > Stefan > > --=20 Anything I seem to state should be taken as a question. I am at least 77 and feeble. --00000000000072bfb80611b088e2 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
=C2=A0If so, we'd be interested to see your code to tr= y and improve our compiler.

I hope this helps.=C2=A0 If = not, please let me know.



<= div class=3D"gmail-adn gmail-ads" style=3D"border-left:none;padding:0px;dis= play:flex;font-family:"Google Sans",Roboto,RobotoDraft,Helvetica,= Arial,sans-serif;font-size:medium">

Robert Boyer=C2=A0<robertstephenbo= yer@gmail.com>

<= /td>
4:19=E2=80=AFPM (1 hour ago)
3D""
3D""Reply to all
3D""
to=C2=A0Andrea= s,=C2=A0Eli,=C2=A069249,=C2=A0Andrea,=C2=A0Stefan,=C2=A0rms
=
<= div dir=3D"ltr">
This message is about how imp= ortant DECLARE and THE are.=C2=A0 If you do not
handle DECLARE and THE right, people will laugh=C2=A0at nati= ve-compile.

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

<= div>I got SBCL with the command=C2=A0sudo a= pt-get 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 (loop (c= ond ((<=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=C2=A0(foo-with-declare 8))
Evaluation took:
=C2=A0 0.12= 5 seconds of real=C2=A0time
=C2=A0 0.123= 203 seconds of total run=C2=A0time=C2=A0(0.= 123193 user, 0.000010 system)
=C2=A0 98.40% CPU
=C2=A0 135,905,516 pr= ocessor cycles
=C2=A0 0 bytes consed
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 (return sum)))
=C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 (incf i))))
WARNING: redefining COMMON-LISP-USER::FOO-WITHOUT= -DECLARE in DEFUN
FOO-WITHOUT-DECLARE
* (tim= e=C2=A0(foo-without-declare 8))
Evaluation took:
=C2=A0 1.080 = seconds of real=C2=A0time
=C2=A0 1.07293= 2 seconds of total run=C2=A0time=C2=A0(1.07= 2932 user, 0.000000 system)
=C2=A0 99.35% CPU
=C2=A0 1,181,369,303 pr= ocessor 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= 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 <schwab@linux-m68k.or= g> wrote:
On Feb 18 2024, Robert Boyer wrote:
> Furthermore, such declare forms are necessary for life as we know it<= br>> in the free world, so that fixnum arithmetic can be used where
&= gt; appropriate!

If you are programming in Emacs Lisp, you need to f= ollow the rules of
Emacs Lisp.

--
Andr= eas Schwab,=C2=A0schwab@linux-m68k.org
GPG Key fingerprint =3D 7578 EB47 D4E5 4D69 2= 510=C2=A0 2552 DF73 E780 A9DA AEC1
"And now for something completel= y different."


--
Anything I seem to state shoul= d be taken as a question.=C2=A0 I am at least 77 and feeble.
=
Reply allReplyForward<= /span>

On Sun, Feb 18, 2024 at 5:32=E2=80=AFPM Stefan Monnier <monnier@iro.umontreal.ca> wrot= e:
> ;; Howev= er, (native-compile "compile-bug.el") results in the following > error message:
>
> ;; Compiling file
> /mnt/chromeos/GoogleDrive/MyDrive/Linux/working/compile-bug.el at Fri = Feb
> 16 08:25:19 2024
> ;; compile-bug.el:2:45: Warning: Unknown defun property =E2=80=98fixnu= m=E2=80=99 in foo
> ;; compile-bug.el:2:45: Warning: Unknown defun property =E2=80=98vecto= r=E2=80=99 in foo

First thing: these are not error messages!=C2=A0 They're *warnings*!
`batch-byte-compile` also gives those warnings, because ELisp does not
know those declarations.=C2=A0 The native compiler does support some type annotations, but they do not take this shape.

I presume you took those from some other Lisp dialect, but that won't d= o
you much good.=C2=A0 Scheme is not Clojure is not Common Lisp is not ELisp = ...

BTW, A more recent Emacs would give you an additional warning:

=C2=A0 =C2=A0 Warning: file has no =E2=80=98lexical-binding=E2=80=99 direct= ive on its first line

So, I see no bug.=C2=A0 Did the resulting native-compile misbehave in
any way?=C2=A0 I presume you're worried about its performance.
If so, do you have concrete code where you measured the performance and
were disappointed and where you have good reasons to believe that type
annotations would make a difference?=C2=A0 If so, we'd be interested to= see
your code to try and improve our compiler.


=C2=A0 =C2=A0 =C2=A0 =C2=A0 Stefan



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