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: weak hash tables Date: Sat, 06 Jul 2024 18:30:04 +0000 Message-ID: References: <87msmu1uy5.fsf@gmail.com> <87cynq1sx0.fsf@gmail.com> 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="19705"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Helmut Eller , Eli Zaretskii , 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 Sat Jul 06 20:55:45 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 1sQAZV-0004v7-Mh for ged-emacs-devel@m.gmane-mx.org; Sat, 06 Jul 2024 20:55:45 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sQAYi-0002Yt-22; Sat, 06 Jul 2024 14:54:56 -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 1sQAAm-0004EP-6q for emacs-devel@gnu.org; Sat, 06 Jul 2024 14:30:12 -0400 Original-Received: from mail-4316.protonmail.ch ([185.70.43.16]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sQAAk-0004c1-1Q; Sat, 06 Jul 2024 14:30:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1720290607; x=1720549807; bh=XO3iE6m3p4b870Z0PxQU0QIQbJKzSReCuY/zx2rvywE=; 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=GIeaMWnT8vwjM4BnIxKGHEmadiGa5aydc8YDMKA8unIbYCkkelik6Yts7+zVCr117 pJ8hFHyEApCJlq62tdAH1AWPBWSyopCdui9lpQn/IcRXCoaHpCHnRA65yt9Imq7snQ t+8N9Pu6nCbb+yBlLrJ07+ti+t+1+vzM/GALn4OmlD5dZ3ORwPQsyqGOLOJfKhJ10z nLHM49wKtXNdsEHUQadbPN8AHAOl2nzrsnwNLv620vOKbJBuiHASVcP62QbEyyRhdb +H3CqG4upKOU9v1Prh/yFzFdoLXPtkVAGbiqIf6oyQfNkPVbIBGjaD0gIEwMEaMxKi LiwWRVniHMIHA== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 9b215fabe8cbc3f198ba7921a053249464808009 Received-SPF: pass client-ip=185.70.43.16; envelope-from=pipcet@protonmail.com; helo=mail-4316.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=ham autolearn_force=no X-Spam_action: no action X-Mailman-Approved-At: Sat, 06 Jul 2024 14:54:55 -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:321458 Archived-At: On Saturday, July 6th, 2024 at 17:28, Gerd M=C3=B6llmann wrote: > Pip Cet pipcet@protonmail.com writes: >=20 > > > We have already this in bignum.c > > >=20 > > > mp_set_memory_functions (xmalloc, xrealloc_for_gmp, xfree_for_gmp); > > >=20 > > > Haven't read the GMP docs yet, but that looks like something that cou= ld > > > be used. > >=20 > > Patch attached, couldn't resist :-) >=20 >=20 > Haha :-). I'm all for it! >=20 > > Memory usage is perfectly acceptable with this patch, but it does do a > > lot of GC. >=20 >=20 > What do the timings say? Horrible things. Unacceptably slow. Sufficiently so that I looked into the = generation parameters and randomly changed them, and now it's faster than v= anilla Emacs?! Does that make sense to you, or is it more likely I'm being = tricked by something silly like CPU speed? All I did was change: - mps_gen_param_s gens[] =3D { { 128000, 0.8 }, { 5 * 128000, 0.4 } }; + mps_gen_param_s gens[] =3D { { 64000, 0.8 }, { 5 * 64000, 0.4 }, { 10 * = 64000, 0.3 }, }; but that was a totally random guess... Again, I may just be doing something wrong. > > > > I believe Eli is right, though, that we should deviate from what Em= acs > > > > usually does as little as possible until we've got things working. > > > > That means just keeping track of how much we've allocated and calli= ng > > > > garbage_collect via maybe_garbage_collect, I think. > >=20 > > > Can you explain? I mean I agree in general, but in this case I'm not = so > > > sure. What I've currently implemented is basically a function of the > > > number of allocated finalizable objects and only finalizable objects = pay > > > the price. The size of allocated memory overall, i.e. counting the by= tes > > > in alloc_impl doesn't contain the information. > >=20 > > But it's probably a better indicator of how much GC activity happened, > > and that influences how many finalization messages there would be, > > assuming that an approximately constant percentage of objects is > > finalizable... >=20 >=20 > Hm. I'm not really convinced the total amount allocated is a better > predictor for how many finalzation msgs we might expect than the real > number of objects for which we might expect finalization messages. Now that you put it like that, maybe the case I've been worrying about (pha= se one of the program creates a huge number of live finalizable objects; ph= ase two stops creating them; finalizable objects never get finalized becaus= e no new ones are being created) isn't that likely. Anyway, your code works= , so it wins :-) > But whatever. Something for later, maybe. Definitely. Pip