From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#46326: 27.1.50; Excessive memory allocations with minibuffer-with-setup-hook Date: Fri, 23 Apr 2021 17:27:23 -0400 Message-ID: References: <62c490ed0d8d24d8b259ac1ba55ea79e@mendler.net> <781821e3-2b06-e946-6616-806f5a83540d@daniel-mendler.de> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="23885"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.0.50 (gnu/linux) Cc: jakanakaevangeli@chiru.no, 46326@debbugs.gnu.org To: Daniel Mendler Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Apr 23 23:29:27 2021 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 1la3Md-00067D-2H for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Apr 2021 23:29:27 +0200 Original-Received: from localhost ([::1]:44618 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1la3Mc-0002O2-5l for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 23 Apr 2021 17:29:26 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:34726) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1la3LG-0001dV-Lz for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 17:28:02 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:55741) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1la3LG-0003C2-DY for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 17:28:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1la3LG-0000Yv-9I for bug-gnu-emacs@gnu.org; Fri, 23 Apr 2021 17:28: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: Fri, 23 Apr 2021 21:28:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 46326 X-GNU-PR-Package: emacs Original-Received: via spool by 46326-submit@debbugs.gnu.org id=B46326.16192132542129 (code B ref 46326); Fri, 23 Apr 2021 21:28:02 +0000 Original-Received: (at 46326) by debbugs.gnu.org; 23 Apr 2021 21:27:34 +0000 Original-Received: from localhost ([127.0.0.1]:39054 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1la3Ko-0000YH-Fz for submit@debbugs.gnu.org; Fri, 23 Apr 2021 17:27:34 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:34563) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1la3Km-0000Y4-R2 for 46326@debbugs.gnu.org; Fri, 23 Apr 2021 17:27:33 -0400 Original-Received: from pmg3.iro.umontreal.ca (localhost [127.0.0.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id EF2A1440B4D; Fri, 23 Apr 2021 17:27:26 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg3.iro.umontreal.ca (Proxmox) with ESMTP id F14F4440B11; Fri, 23 Apr 2021 17:27:24 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1619213244; bh=1NKnoKqah5rfLShkcPOUhRSGkXVGERy9rRLnrjgOokY=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=NGBqXD+82m1+gXDaRj8NbsDkEVcTRT6kdTpBOspjoexkbHyJZO/9m1eSQZRZW36Xh XNRHK1aOeFdszYSwJF4XAljBA2enHf0ipZQLBMaZQr3aYWw+KkCG4mF1ok1TqqdUcD XAGLu+Kb07RRCDUZbAupN+XFvIiPK5BQA+si5CioqaoWYWZReeNiZ36cW6AQf81LkI 6sIbEBwPF7bFStHu0m8b1ARu/8ovp32YkZppwNCfDIFLHfpx4IL3nv+OYjZstPjkkx j7R9oa+urPv3+Na5a5cqw9hjaWLtIYp/ehZ0YW2OWGP6Y7toF1a2+6dM0ssPEgHOIH mAVTKZY8FBKJw== Original-Received: from alfajor (104-222-126-84.cpe.teksavvy.com [104.222.126.84]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id C4713120176; Fri, 23 Apr 2021 17:27:24 -0400 (EDT) In-Reply-To: <781821e3-2b06-e946-6616-806f5a83540d@daniel-mendler.de> (Daniel Mendler's message of "Fri, 23 Apr 2021 21:28:24 +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:204762 Archived-At: jakanakaevangeli@chiru.no [2021-04-23 22:34:06] wrote: > Daniel Mendler writes: >> For me it seems to fix the issue. @jakanakaevangeli, can you confirm? > Yup, confirmed. Thanks, pushed to `master`. Maybe we should consider it for `emacs-27` since it's a regression in Emacs-27. Eli, WDYT? > The crucial part this patch does to fix this issue is > removing depth info to avoid leaks, which is also directly related to > bug46414. Indeed, thanks. > For me it seems to fix the issue. @jakanakaevangeli, can you confirm? > I would still prefer to see a "proper fix". But given the backward > compatibility requirements such a fix may not exist. > Perhaps one could introduce some deprecation behavior. If a hook is removed > and the object is not found via eq but found via equal, then print > a warning? And then change the add-hook/remove-hook functions to eq only in > some later version. I suggest you `M-x report-emacs-bug` and make such a proposal. We already have 3 places where we bump into this (`set-transient-map`, `eval-after-load`, and `minibuffer-with-setup-hook`). > Furthermore as a stop-gap measure one may still apply my patched > symbol-indirection `minibuffer-with-setup-hook`, and revert it once the > proper fix has been applied. Yes, that was indeed the intention. It's been pushed as well. > (Using the symbol indirection seems to have other debuggability > advantages. Closures are not particularly nice to debug in elisp, I hope we > will also see some improvements regarding that. We already have had some improvements (if byte-compiled, they should print with a hyperlink that shows the disassembled bytecode, which is a lot more palatable than the raw bytecode we used to present). > It is at least on my Elisp wishlist to have better introspection for > closures, location info etc.) There's indeed still a fair bit of progress to be made. > Note that `set-transient-map` already uses the symbol indirection. It may > make sense to link to this bug from there such that one can adjust this > function also at some later point depending on the resolution of this > issue. The comment in `set-transient-map` reads like a bug to me > "Don't use letrec, because equal (in add/remove-hook) would get trapped in > a cycle." :) Yes, it's (or was) clearly a bug in `equal`. IIRC our current `equal` is better in this respect, but I'd be surprised if we can't make it get stuck in a loop in some cases. Stefan