From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Lynn Winebarger Newsgroups: gmane.emacs.devel Subject: Re: Ideal performance of ELisp Date: Sat, 13 Aug 2022 10:56:51 -0400 Message-ID: References: <83mtceupbx.fsf@gnu.org> <83lerxvfnu.fsf@gnu.org> <838rnxvdcq.fsf@gnu.org> <83r11ptksn.fsf@gnu.org> <83a68dti6w.fsf@gnu.org> <874jykzvx9.fsf@yahoo.com> <83fsi4sttn.fsf@gnu.org> <838rnws5c7.fsf@gnu.org> <838rntocb8.fsf@gnu.org> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="00000000000083ac5605e6209c68" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="25500"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Po Lu , Alan Mackenzie , emacs-devel , Yuan Fu To: Stefan Monnier Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Sat Aug 13 16:57:44 2022 Return-path: Envelope-to: ged-emacs-devel@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 1oMsa8-0006V2-7f for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Aug 2022 16:57:44 +0200 Original-Received: from localhost ([::1]:39016 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1oMsa7-0002gt-03 for ged-emacs-devel@m.gmane-mx.org; Sat, 13 Aug 2022 10:57:43 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:47728) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1oMsZX-000215-HJ for emacs-devel@gnu.org; Sat, 13 Aug 2022 10:57:07 -0400 Original-Received: from mail-pj1-x1030.google.com ([2607:f8b0:4864:20::1030]:42646) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1oMsZV-0001Qg-UL; Sat, 13 Aug 2022 10:57:07 -0400 Original-Received: by mail-pj1-x1030.google.com with SMTP id d65-20020a17090a6f4700b001f303a97b14so3295878pjk.1; Sat, 13 Aug 2022 07:57:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc; bh=XWgJ/HQp/aRreo/Nq5xmltCOnJiWxJiMl+w4cXB+Xhs=; b=e+hS6Xt2z7DfgrBOSd/3IMOcGTarTOqmQGGKQrLSW/5KwaBTY2FUC3TzgpkG8pGk// cS3gM/RuXCqf4mUMbecYSbhbmRw+50OuiooUtE2uly0wnTMn/67Pu83rqL8JI8HE02S3 hHvRRzFBp4ZhIldhrUrUiqTYi4tVpWhtG0/bE5FtAC3aD5lNLBgIASz4BHkBrZk0CLhC 7XPlvMEbsUtvCEEgOb2lE/2nMsTy+vNe6gUdsXTnTlp1xlTpDhYYUErDrosAaUiiuuJN oXit78u+jNvo9muf0Gscpe6fd7rFwHbibq//rmoIHdEBCNGGoxRmu82eVbUGi7HqKiiN gEYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc; bh=XWgJ/HQp/aRreo/Nq5xmltCOnJiWxJiMl+w4cXB+Xhs=; b=spHasaGaXmGBDKmeNjDXt+Qq/db1LO6xieKoV9EF36QyliWfwFf6HZZR1suacUxO/g vq3kJMCIqHbIP86P9cEAwwUzUaUx7VOl1YB3wqhwVnMg7uLL+je2/WGYg7Z70OmSIUvD EKaxfjNWxystvl0Y8K881kJljjLGtLPfma24Cpp9Btgs+/lJj8ZQ1t56ty2kdgJNubsV eRr44jIWDaXVngSpppt6eDpCkQcMSkDO2VmnJel/AN2Oe0KvleEkfZMMmOSPjBpSpKZT uI8mUAvDDzJFrf0RMJJDN92QiQWOur8SRejVs3x/VRIO2dVIu8jM6zlWtdrcxmHXLpps oeVA== X-Gm-Message-State: ACgBeo1DMT+qx7Yd8IWij9hF5lpgVuRLeRRWNUs3OmfqW4HYqcw4sAyT QHL5AZm41eqTiNAVANY7ZD9d9Yo++LQSpQN9wes= X-Google-Smtp-Source: AA6agR4wJOPyTPBqx585T26/KlGC0mZUE4c7qLa404mHeafCRwLzQwgUBcob1J9peXast3LpJohGkxTJ451NIXvAewI= X-Received: by 2002:a17:90a:2948:b0:1f3:1b42:a810 with SMTP id x8-20020a17090a294800b001f31b42a810mr9630271pjf.203.1660402622768; Sat, 13 Aug 2022 07:57:02 -0700 (PDT) In-Reply-To: Received-SPF: pass client-ip=2607:f8b0:4864:20::1030; envelope-from=owinebar@gmail.com; helo=mail-pj1-x1030.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Original-Sender: "Emacs-devel" Xref: news.gmane.io gmane.emacs.devel:293418 Archived-At: --00000000000083ac5605e6209c68 Content-Type: text/plain; charset="UTF-8" On Sat, Aug 13, 2022, 10:07 AM Stefan Monnier wrote: > >> > Once the VM supports proper tail recursion, it's straightforward to > >> > generate automata that never perform a function call, at least not as > part > >> > of the recognizer. > >> > >> It was straightforward beforehand as well (using a `while` loop instead > >> of recursion). And if you do use recursion, then it's not very much > >> simpler with `lexical-binding` than without because you still have to > >> take into account the possibility that the function gets redefined > >> during your recursion :-( > >> > > > > I think you're mistaking self-tail recursion for tail recursion. > > No, I was simply restricting the discussion to the case you mention of > "generat[ing an] automata", in which case you usually have enough > control over the generated code to use a `while` loop if desired. It's true you can avoid funcall dispatch overhead that way, but unless I'm missing something you are stuck with the overhead of the while loop plus whatever conditional branching mechanism you would use for dispatching to a state label, as opposed to simply jumping to the contents of a register. I'm not 100% on whether there's an ELisp construct that the byte compiler can turn into byte code that uses a table of labels for condirional dispatch the way a switch statement may be implemented in C. Lynn > --00000000000083ac5605e6209c68 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Sat, Aug 13, 2022, 10:07 AM Stefan Monnier <monnier@iro.umontreal.ca> wrote:
=
>> > Once the VM supports pro= per tail recursion, it's straightforward to
>> > generate automata that never perform a function call, at leas= t not as part
>> > of the recognizer.
>>
>> It was straightforward beforehand as well (using a `while` loop in= stead
>> of recursion).=C2=A0 And if you do use recursion, then it's no= t very much
>> simpler with `lexical-binding` than without because you still have= to
>> take into account the possibility that the function gets redefined=
>> during your recursion :-(
>>
>
> I think you're mistaking self-tail recursion for tail recursion.
No, I was simply restricting the discussion to the case you mention of
"generat[ing an] automata", in which case you usually have enough=
control over the generated code to use a `while` loop if desired.

It's true = you can avoid funcall dispatch overhead that way, but unless I'm missin= g something you are stuck with the overhead of the while loop plus whatever= conditional branching mechanism you would use for dispatching to a state l= abel, as opposed to simply jumping to the contents of a register.=C2=A0 I&#= 39;m not 100% on whether there's an ELisp construct that the byte compi= ler can turn into byte code that uses a table of labels for condirional dis= patch the way a switch statement may be implemented in C.

Lynn=C2=A0



=C2=A0
--00000000000083ac5605e6209c68--