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: Tue, 02 Jul 2024 06:23:45 +0000 Message-ID: References: <2syUQ04IbTWqDJjMfKSrtzWMWmFGq1GIOwSxv_r6BEyNDtk7ADADKjZk-90g9tSS9SKWppkiq6_zihUtsoE1spiopaOI6-v9inQrGxwMyCs=@protonmail.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="23494"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , Helmut Eller , Emacs Devel To: =?utf-8?Q?Gerd_M=C3=B6llmann?= Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 02 13:07:54 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 1sObMY-0005ta-5y for ged-emacs-devel@m.gmane-mx.org; Tue, 02 Jul 2024 13:07:54 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sObLT-0004s4-Qu; Tue, 02 Jul 2024 07:06:47 -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 1sOWvk-0000Vo-0E for emacs-devel@gnu.org; Tue, 02 Jul 2024 02:23:56 -0400 Original-Received: from mail-40134.protonmail.ch ([185.70.40.134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sOWvg-0007r2-Eh for emacs-devel@gnu.org; Tue, 02 Jul 2024 02:23:54 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1719901429; x=1720160629; bh=SHRixgU3KMrBjR/xfwyGKbUR0r3tCbjevG4DH98grVI=; 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=XTd98feiPoBD1y2EAP96SqdIX1ntWDnJuM8r8CeopexaldaR0QNZp//4bUZkYIlhX JbP5mgy+fsgDWfM5T1bv3a2OCvUHuaKv3XizYF+7vlw9LsgYEXBdm9+/dnPB9y0oZt 28EDRLmt20UNFC+lU4rowY3MAo8ciu02kz1TP5Sl50JFopkWH+e8iA5k/7Pb87Qu1f q86kqlUQusYNXldpmSxRumPq8DZUJUGWJZW7KC4epAKzd/lc2PJYzX9GbPKXm2cvhz sPK1cnWmdivlC9XbK/5sG2TAMpGNuREbkbw9sZ/uipslclwy8LzFNY72pW/l9GbA42 RaOFirlxInIxg== In-Reply-To: Feedback-ID: 112775352:user:proton X-Pm-Message-ID: 286269affe22c9e90b3e12cf689fe086d9c6522c Received-SPF: pass client-ip=185.70.40.134; envelope-from=pipcet@protonmail.com; helo=mail-40134.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: Tue, 02 Jul 2024 07:06:43 -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:321120 Archived-At: On Tuesday, July 2nd, 2024 at 05:47, Gerd M=C3=B6llmann wrote: > Pip Cet pipcet@protonmail.com writes: >=20 > > Also, any opinions on :weakness 'key-or-value? Can we just not support = it and use strong hash tables instead? >=20 >=20 > So, after some more reading, I think I have an opinion. Let me read what > it is :-) >=20 > The design supports 1 vector of weak references, and 1 vector of > strong references. So either keys or values can be weak but not both. Why not? I may be missing something obvious, but the scan method is allowed= to modify the scanned object, right? We're doing that in the weak-key case= anyway. So what I'm currently doing is creating a single vector containing all keys= , then all values, for key-and-value hash tables. If the key gets splatted,= the value gets splatted right away and everything works as it should. If t= he value gets splatted, we've already decided to keep alive the key, but th= at's okay as it's only a weak reference. > Let's say that W(O) returns true when object O is references from weak > references only. AFAICT, the implementation of W in MPS requires > allocation with rank weak to get weak references. That's my understanding too. > key/value pairs are then removed from a hash table when >=20 > Weakness Predicate > ---------------------------------------- > key W(key) > value W(value) > key-and-value W(key) and W(value), > key-or-value W(key) or W(value). Hmm. I think I have key-and-value and key-or-value reversed, then... > I'd say that neither key-and-value nor key-and-value can be > implemented because both require 2 weak parts for implementing W. Sorry, I still don't understand why. > In Emacs itself, I see from git grep that :weakness key, value, and t > are being used, where t means key-and-value. Haven't checked for which > use cases t is used, though. What surprised me is that there are plenty of hash tables that are both wea= k and use equal as a predicate. That doesn't make much sense to me... > Anyway, we're better off than before :-). On 64-bit systems. 32-bit systems are still broken, I'm afraid, and while m= y patch fixes the crash I've seen on i386 Debian, Eli's crash looked very d= ifferent and may not be fixed by it. Also, there's the whole caution thing about weak objects containing only un= aligned words or words pointing directly to a base object, which is only re= levant on Unix/i386, IIRC. (MPS emulates instructions to simulate fine-grai= ned barriers, which is a really cool idea; I'd still like an option to turn= it off though...). That would mean we have to replace Lisp_Objects and use= the ptr member of our union (and that's the reason I'm using fixnums rathe= r than plain integers for the hash). Anyway, thanks a lot, so far. Sorry I'm being dense about the key-and-value= thing. Pip