From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Pip Cet Newsgroups: gmane.emacs.devel Subject: Re: MPS: out-of-memory Date: Mon, 08 Jul 2024 16:45:20 +0000 Message-ID: References: <86a5iu4tiy.fsf@gnu.org> <87msmu1uy5.fsf@gmail.com> <865xtg14hd.fsf@gnu.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="30187"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , acorallo@gnu.org, eller.helmut@gmail.com, emacs-devel@gnu.org To: =?utf-8?Q?Gerd_M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Mon Jul 08 19:39:05 2024 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 1sQsKN-0007db-DV for ged-emacs-devel@m.gmane-mx.org; Mon, 08 Jul 2024 19:39:03 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQsJe-000603-Ca; Mon, 08 Jul 2024 13:38:18 -0400 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 1sQrUg-0000qT-LP for emacs-devel@gnu.org; Mon, 08 Jul 2024 12:45:38 -0400 Original-Received: from mail-4322.protonmail.ch ([185.70.43.22]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQrUe-0007Vd-DG; Mon, 08 Jul 2024 12:45:38 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1720457133; x=1720716333; bh=LecR7HNdWPeWuWBCfsSsIYzHEptg/w67TqvRy6D4gLk=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=oe1XA1DSFFiPVErdTXI3tps594sQmBahvDpi54GayN2cgpWveoet9SOAPDtIDrBQa FvGyEqGBAOsEheSiE7LTRVYCddy6i58TIS4NHhBSzVHCd5t0JXWl8MIlLBARtq8v1M NmZp2ox9LmJPgnIUeRSg/l87A5apWQB/gf3R2Lzrr1QhNtD9hDUXGrjU4XeT0AzdHY pGsZim8WdscbitQaTUhhq4up7mN+ZBKEHEjtDP4TEzm7o4af7s8n5a6aikCn/8IE6D LICrXiSiv1GpA0OK7B8kdX7Qtxt4GQO75WVr9VZ4HJvzyeKBotEdftV1WXi7fmaAAD RCaHTVSQbcYmw== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 137fb2b725668003afcf40031d1413f20fabed7b Received-SPF: pass client-ip=185.70.43.22; envelope-from=pipcet@protonmail.com; helo=mail-4322.protonmail.ch 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, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Mon, 08 Jul 2024 13:38:12 -0400 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-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.devel:321543 Archived-At: On Monday, July 8th, 2024 at 13:46, Gerd M=C3=B6llmann wrote: > Eli Zaretskii eliz@gnu.org writes: > > Btw, the current GC in Emacs has a feature for when Emacs runs out of > > memory: it sets some small amount of memory aside, and uses it when > > "memory-full" condition happens, because some memory is needed to show > > the memory-full error message, and then shut down in an orderly > > fashion: > >=20 > > void > > memory_full (size_t nbytes) > > { >=20 > ... >=20 > > See also refill_memory_reserve. > >=20 > > Do we perhaps need something like that with MPS? >=20 >=20 > Yes, I think that's important, and also handling the case of getting > errors codes from MPS in general. I think we might want to distinguish the two cases: MPS might die, sure, bu= t it looks like we need an out-of-memory mechanism separate from MPS to avo= id assertion violations. > As one can see, igc as a whole is in a certain state, igc_state. The > idea is that the state changes to IGC_STATE_DEAD when something fatal > happens. In that state, malloc is used is used for allocating Lisp > objects instead of MPS. That lets Emacs shut down gracefully without > entering MPS recursively as it was before I added the state. I've seen that work, and I've seen it not work. Better than nothing :-) > Such state changes are currently done when checking the return code of > an MPS API function and when assertions fail. >=20 > Seems to work as expected, as I could see in a couple of backtraces from > Ihor I believe showing the set_state (IGC_STATE_DEAD), and from my own > experience. But maybe someone has an idea how to improve it. If I understood Helmut correctly, he wants a mechanism to avoid thrashing a= fter exceeding the memory limit. Maybe we need a special state for that, in= which we stop the GC but continue using our memory while the user quits an= d goes to buy more RAM? Speaking of memory issues in general, I'm currently seeing pure space overf= lows, after changes which should affect weak objects exclusively. Which is = really odd, because weak objects aren't purecopied! Still investigating tha= t one, but it's possible I'll just give up and bump pure space. In any case, we end up segfaulting because we still try to run GC after pur= e space overflowed. I'll push a fix for that, but I can't promise to test t= he case of overflowing pure space very much. Pip