From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED!not-for-mail From: Lars Ingebrigtsen Newsgroups: gmane.emacs.bugs Subject: bug#33275: 27.0.50; Image cache pruning Date: Fri, 09 Nov 2018 13:26:50 +0100 Message-ID: References: <83va5bcxxu.fsf@gnu.org> <83sh0fcx2r.fsf@gnu.org> <83o9b3cu4f.fsf@gnu.org> <83bm72ciyz.fsf@gnu.org> NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: blaine.gmane.org 1541766312 3203 195.159.176.226 (9 Nov 2018 12:25:12 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Nov 2018 12:25:12 +0000 (UTC) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 33275@debbugs.gnu.org To: Eli Zaretskii Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Nov 09 13:25:08 2018 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by blaine.gmane.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL5qV-0000hi-LX for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 13:25:07 +0100 Original-Received: from localhost ([::1]:33521 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL5sb-0000OZ-Q5 for geb-bug-gnu-emacs@m.gmane.org; Fri, 09 Nov 2018 07:27:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:37153) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gL5sQ-0000OE-C5 for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2018 07:27:07 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gL5sP-0007VS-9w for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2018 07:27:06 -0500 Original-Received: from debbugs.gnu.org ([208.118.235.43]:38031) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gL5sL-0007UV-W7 for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2018 07:27:04 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gL5sL-0001An-MQ for bug-gnu-emacs@gnu.org; Fri, 09 Nov 2018 07:27:01 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Lars Ingebrigtsen Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Fri, 09 Nov 2018 12:27:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33275 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: Original-Received: via spool by 33275-submit@debbugs.gnu.org id=B33275.15417664144494 (code B ref 33275); Fri, 09 Nov 2018 12:27:01 +0000 Original-Received: (at 33275) by debbugs.gnu.org; 9 Nov 2018 12:26:54 +0000 Original-Received: from localhost ([127.0.0.1]:42289 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL5sE-0001AP-BJ for submit@debbugs.gnu.org; Fri, 09 Nov 2018 07:26:54 -0500 Original-Received: from hermes.netfonds.no ([80.91.224.195]:49478) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gL5sC-0001AI-VZ for 33275@debbugs.gnu.org; Fri, 09 Nov 2018 07:26:53 -0500 Original-Received: from cm-84.212.221.165.getinternet.no ([84.212.221.165] helo=stories) by hermes.netfonds.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.84_2) (envelope-from ) id 1gL5sA-0002IL-EV; Fri, 09 Nov 2018 13:26:52 +0100 Face: iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAElBMVEWHhWtoTzJ8ZTuAdVa8 tIZjKBaOPNBXAAACdklEQVQ4jW2Uy5LjIAxFZcPsI3D2PJw9D3tPbGXfdjf//ysjSDpTUxVV2RAd pCuhJFDos8HmXFI+KceGp3UHokUfJwbWOW19tAoVokPleEEGObkPNsPoP/kZbD61hfeZH2JJ1z4Y GJGXNDvny+aMIPZxcjCwPXl7FPs4wmpeWcM19c2PPYPgvWkdNODVU+wlW8ZXVa6XNQ+coBVubr1X 8z5IozN904vcWsTb/G+rBlgjcbmoXh6rHP42OGRlw+AsXx2fQHt1jdkJxmA1FKWjispaRqc9lNUT 7GEAKAPkIFBblSNiRgwL7MB+IbLIJcZ4WTKfiBkakLAnBjMIldYgvJCiAQEzDzJkKCX7KIvwKYtQ GEgGe8hZFsieZy0SQDYBSoswmcFQohlkCSMIIVgjLESpSd4hx5XA70GMHWRHhqtd7jOAJOBMIjWQ QY7aWjGAjF4SVwi5A9a/YooaAqQgnPf8gp5Kys3mqEcnioBtjNmkAB1weB6mPUKrfct+3CLnKUBU xqRZl2QgWgzsG/QIItTp4IoK8CEyQXbwuND+pSwDGKumhSLKPV9meBgaqnYXgOEquTFaVRgVTPD4 dr5+Xz0DvUg10+pmd/E/8KjnZa3WMviRNMx0dy7OWwMHz/7WAN8mzrQhVtNBdZp/OgxgKBuDSxHy TwP2dvqhifM13xnwUGhlYNuXav16prpTB7KBg0GqLUI+gW2RXTy6W32lGjkNTvyam/jpkEG+ToUU +276DRCPWitqCSe5beVLUr3cAxV7ufzae6oLbbWD88BrxXpt4HbeTrk8nqA28M9wmNYXwPqf4XJ9 gQ82AfFsIcP730gW2Td/AYait0ePzXUgAAAAAElFTkSuQmCC In-Reply-To: <83bm72ciyz.fsf@gnu.org> (Eli Zaretskii's message of "Tue, 06 Nov 2018 17:40:36 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:152213 Archived-At: Eli Zaretskii writes: > After thinking about this and looking at the code, I don't think I > understand your proposal(s). Here are the issues that I saw with what > I think you proposed: > > . The hash table used by the image cache is not a Lisp hash-table, so > weakness doesn't apply. We cache pointers to C structs, so using a > Lisp hash-tables would need "some work". Yeah, it'd have to be rewritten substantially to use Lisp hash tables. > . The code you show above is called from redisplay, so it will not be > executed as long as a Lisp program (such as the one you show at the > beginning of this discussion) runs, and you will still have the OOM > killer get you before that code get a chance to clear the cache. That's true, but calling the cache pruning function from the function that enters images into the cache would be trivial, I think. > . Running such code from GC could be tricky, because freeing images > needs to remove references of those images from the glyph matrices, > and that cannot be safely done from arbitrary places. Ah, I see. Yes, that's a major complication... > I think if we want to prevent the OOM killer from killing Emacs due to > many cached images, we should inspect inside cache_image the current > VM size of the process (like system_process_attributes does), compare > it to the memory limits, and display a warning and/or signal an error > when we get dangerously close to the limit. I think that sounds like a good idea, yes. Having such a check is good for Emacs sanity, but we should also have a way for programmers to avoid ending up in that pathological situation to begin with. So either a DONT-CACHE parameter to `image-size' or just a docstring thing. :-) -- (domestic pets only, the antidote for overdose, milk.) bloggy blog: http://lars.ingebrigtsen.no