From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier via "Bug reports for GNU Emacs, the Swiss army knife of text editors" Newsgroups: gmane.emacs.bugs Subject: bug#55414: 29.0.50; Byte compilation error for the modus-themes Date: Thu, 26 May 2022 11:20:14 -0400 Message-ID: References: <87lev296hl.fsf@protesilaos.com> <87zgjihlmw.fsf@gnus.org> <83zgjhiv8l.fsf@gnu.org> <83wnelirxq.fsf@gnu.org> <83tu9pinsj.fsf@gnu.org> <87tu9p8r7d.fsf@protesilaos.com> <83r14tii8m.fsf@gnu.org> <83ilpx7l8c.fsf@gnu.org> <87tu9gyki9.fsf@protesilaos.com> <83czg47bz7.fsf@gnu.org> <87v8tv7dht.fsf@protesilaos.com> <83mtf75grb.fsf@gnu.org> <87h75el2f5.fsf@protesilaos.com> <83r14h4uyi.fsf@gnu.org> <87tu9crg7f.fsf@protesilaos.com> <838rqopm0q.fsf@gnu.org> <875ylscxre.fsf@gnus.org> Reply-To: Stefan Monnier Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="19723"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/29.0.50 (gnu/linux) Cc: acm@muc.de, Eli Zaretskii , Protesilaos Stavrou , 55414@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Thu May 26 17:21:15 2022 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 1nuFIZ-0004ws-C7 for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 May 2022 17:21:15 +0200 Original-Received: from localhost ([::1]:48378 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nuFIY-0000e5-4x for geb-bug-gnu-emacs@m.gmane-mx.org; Thu, 26 May 2022 11:21:14 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52282) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nuFIM-0000bj-SV for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 11:21:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:37677) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nuFIM-00041T-J4 for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 11:21:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1nuFIM-0001RS-Ex for bug-gnu-emacs@gnu.org; Thu, 26 May 2022 11:21:02 -0400 X-Loop: help-debbugs@gnu.org Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Thu, 26 May 2022 15:21:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 55414 X-GNU-PR-Package: emacs Original-Received: via spool by 55414-submit@debbugs.gnu.org id=B55414.16535784285465 (code B ref 55414); Thu, 26 May 2022 15:21:02 +0000 Original-Received: (at 55414) by debbugs.gnu.org; 26 May 2022 15:20:28 +0000 Original-Received: from localhost ([127.0.0.1]:59803 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuFHn-0001Q5-SA for submit@debbugs.gnu.org; Thu, 26 May 2022 11:20:28 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:45266) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1nuFHj-0001Pn-3X for 55414@debbugs.gnu.org; Thu, 26 May 2022 11:20:26 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id 7A8C4440EB1; Thu, 26 May 2022 11:20:17 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id E9891440CF4; Thu, 26 May 2022 11:20:15 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1653578415; bh=w7EX8X9X8x9s6UyLYIKv1Ir3T7HBgTDCEfWP5wW6aow=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=kBeWlK1V39q5WJpoCxW+CsfHMLJrd2sKjUkBcU7h5NiUYBnkHHIlTYmEnxt6x1DMc D2gGPd9GlN24xgERontVEKlrr6XyO1ZDaiHDGqd8MW7zYSKwb/ABrcF+rSDww3Zch1 QMpW0XKWMtA34CguHopH2DmCLX7KSK7lICxX5oIM3EtSDiQfG+ptDr8mvXTtM3f0Bv I7DbbvZM2wYDJ0NzcdCiTErXzg1m40f/CtjFDn+RuWh3moOBGbxw6nTvG1G2l8ZpEY 9yDz1fnxCb8yYNy241gYXQTP7znvLOOS64SULsiu3eyR+rQ4fKPTuxJJ+4EBawdP0Y EcyaSUHX5Kndg== Original-Received: from alfajor (lechon.iro.umontreal.ca [132.204.27.242]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 45F4B120BC9; Thu, 26 May 2022 11:20:15 -0400 (EDT) In-Reply-To: <875ylscxre.fsf@gnus.org> (Lars Ingebrigtsen's message of "Thu, 26 May 2022 13:57:09 +0200") 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" Xref: news.gmane.io gmane.emacs.bugs:233117 Archived-At: Lars Ingebrigtsen [2022-05-26 13:57:09] wrote: > Eli Zaretskii writes: > >> Lars, is it just me, or are you also concerned by a large increase in >> the default values of these variables? > > I'm not really that concerned in general, but in this case, the entire > problem is apparently due to one function -- > byte-compile--first-symbol-with-pos -- that's very recursive. It could > be rewritten to not be recursive, and these problems would go away > (which we've seen in many contexts now), if I understand correctly. The patch below should significantly reduce the recursion depth (and hopefully make it faster, to boot) because the (loop (cdr form)) call is in tail position (and named-let should hence apply TCO to it). Does it help for modus-themes? Stefan diff --git a/lisp/emacs-lisp/bytecomp.el b/lisp/emacs-lisp/bytecomp.el index 87798288fb5..6e9ad39c6a7 100644 --- a/lisp/emacs-lisp/bytecomp.el +++ b/lisp/emacs-lisp/bytecomp.el @@ -1183,28 +1183,23 @@ byte-compile-abbreviate-file (defun byte-compile--first-symbol-with-pos (form) "Return the \"first\" symbol with position found in form, or 0 if none. Here, \"first\" is by a depth first search." - (let (sym) - (cond - ((symbol-with-pos-p form) form) - ((consp form) - (or (and (symbol-with-pos-p (setq sym (byte-compile--first-symbol-with-pos (car form)))) - sym) - (and (symbolp (setq sym (byte-compile--first-symbol-with-pos (cdr form)))) - sym) - 0)) - ((and (or (vectorp form) (recordp form)) - (> (length form) 0)) - (let ((i 0) - (len (length form)) - elt) - (catch 'sym - (while (< i len) - (when (symbol-with-pos-p - (setq elt (byte-compile--first-symbol-with-pos (aref form i)))) - (throw 'sym elt)) - (setq i (1+ i))) - 0))) - (t 0)))) + (or (named-let loop ((form form)) + (cond + ((symbol-with-pos-p form) form) + ((consp form) + (or (loop (car form)) + (loop (cdr form)))) + ((and (or (vectorp form) (recordp form)) + (> (length form) 0)) + (let ((i 0) + (len (length form)) + elt) + (catch 'sym + (while (< i len) + (when (setq elt (loop (aref form i))) + (throw 'sym elt)) + (setq i (1+ i)))))))) + 0)) (defun byte-compile--warning-source-offset () "Return a source offset from `byte-compile-form-stack'.