From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: =?utf-8?Q?Gerd_M=C3=B6llmann?= Newsgroups: gmane.emacs.devel Subject: Re: MPS: weak hash tables Date: Tue, 02 Jul 2024 07:47:00 +0200 Message-ID: References: <2syUQ04IbTWqDJjMfKSrtzWMWmFGq1GIOwSxv_r6BEyNDtk7ADADKjZk-90g9tSS9SKWppkiq6_zihUtsoE1spiopaOI6-v9inQrGxwMyCs=@protonmail.com> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="11253"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Gnus/5.13 (Gnus v5.13) Cc: Eli Zaretskii , Helmut Eller , Emacs Devel To: Pip Cet Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Tue Jul 02 07:48: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 1sOWN2-0002eH-83 for ged-emacs-devel@m.gmane-mx.org; Tue, 02 Jul 2024 07:48:04 +0200 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sOWM9-0006uf-CB; Tue, 02 Jul 2024 01:47:09 -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 1sOWM8-0006uL-8w for emacs-devel@gnu.org; Tue, 02 Jul 2024 01:47:08 -0400 Original-Received: from mail-ej1-x632.google.com ([2a00:1450:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sOWM5-0003aZ-Gv; Tue, 02 Jul 2024 01:47:06 -0400 Original-Received: by mail-ej1-x632.google.com with SMTP id a640c23a62f3a-a724cd0e9c2so375422166b.3; Mon, 01 Jul 2024 22:47:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1719899223; x=1720504023; darn=gnu.org; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:from:to:cc:subject:date:message-id:reply-to; bh=bKB2JHOQqP53J1Fo8LZjKuIjrctPfKv0ozKNtELzHhE=; b=NzxklcUqcfj+/b2Fm9u3FVdsPRy0oRmI3nSIA03GWdYngu3hwcFIohOfi13U4Vaa9z EJapqe+0sPGJWDj7AW0gggei0IGgIYbpR25pgjbrJfkH0v5yJL+zk50MtcaOmnjvXa+W JKc/4c0QK7nAqsRrDv7+EvZj9aYnfbgLDM2l+j7VsWqbrP1vOuKchQDqmQAvlLAqUDAP yPbQO7RxqSZx0mA9lFM+PWrT4FVUL/MKiWprj56NlCX3Tkpbs3GTS9/akB3jQWOtmpcb dE8qdl/kvRdfptx85n1WcxP1rEAGrl/V30xLSyN4v/Pxx2Q4/mw4mtNYddNtIISFCLRV qhzA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1719899223; x=1720504023; h=mime-version:user-agent:message-id:date:references:in-reply-to :subject:cc:to:from:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=bKB2JHOQqP53J1Fo8LZjKuIjrctPfKv0ozKNtELzHhE=; b=mBeHYRUqNlBt86CY5KolcYXECm64fU/S//2ZeipxKwO/3Vvhdyq06EMFANL7Eh8Hh9 aoXcMy7GkyAJKzoTFRHbodIc0RTau0d7l3H7OW4pLCqqyoSflYqw3d3XfOD1ge147TsA dCjg4k7vQjh43JAg1XuXOL/czuyZEZdAIdd2/3p9kvtueaSfZhuSkNLjiqxDCibxOtE0 yqiyCVak8TVAPfGSVInhv8ENTXTgYeQ0OFGQcjdFhzdIFeF0x2F4jydn+3rkW5xjhMLi im5lnmsJHDICv2BURkZ3rkD56obdLNH2spMBpGa9I+P5e2lQOkfzYXg3Ep4PYdXOUuzK +WAA== X-Forwarded-Encrypted: i=1; AJvYcCWch7wS6OA3ZikdLdK9KgfO6v9HYqYTwsyu6taLn7AlkPXFPEz/n5/PIHDYUPVepXPYyFogcZ9L+pn7vGUs6j5jF15E X-Gm-Message-State: AOJu0YyJ5rusqnYHprLlarvlICeV32vjBx2fFgBgA0S1azCVn/NvTduu mEE+EIi60tlKL41lXubsi+xoqAY2orfjPzN2Ww7FbLc3zrko8dJdHOh1Zw== X-Google-Smtp-Source: AGHT+IEiU+kPG5QoBDiJcatdGb5eNIFNGBpY07739DnvZCvO+8rqelE2e3mOqaihoL7WTXF0xCmfWA== X-Received: by 2002:a17:906:f847:b0:a75:1096:bbb4 with SMTP id a640c23a62f3a-a75144b9bb8mr493317966b.69.1719899222102; Mon, 01 Jul 2024 22:47:02 -0700 (PDT) Original-Received: from pro2.fritz.box (pd9e36129.dip0.t-ipconnect.de. [217.227.97.41]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a752d634721sm109838866b.105.2024.07.01.22.47.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 01 Jul 2024 22:47:01 -0700 (PDT) In-Reply-To: <2syUQ04IbTWqDJjMfKSrtzWMWmFGq1GIOwSxv_r6BEyNDtk7ADADKjZk-90g9tSS9SKWppkiq6_zihUtsoE1spiopaOI6-v9inQrGxwMyCs=@protonmail.com> (Pip Cet's message of "Mon, 01 Jul 2024 23:10:01 +0000") Received-SPF: pass client-ip=2a00:1450:4864:20::632; envelope-from=gerd.moellmann@gmail.com; helo=mail-ej1-x632.google.com 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, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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:321095 Archived-At: Pip Cet writes: > Also, any opinions on :weakness 'key-or-value? Can we just not support it and use strong hash tables instead? So, after some more reading, I think I have an opinion. Let me read what it is :-) 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. 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. key/value pairs are then removed from a hash table when Weakness Predicate ---------------------------------------- key W(key) value W(value) key-and-value W(key) and W(value), key-or-value W(key) or W(value). I'd say that neither key-and-value nor key-and-value can be implemented because both require 2 weak parts for implementing W. 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. It surprises me a bit that key-and-value is used, I must admit. Hm. Also interesting could be what is used outside of Emacs, and for what, of course. I have currently no idea how to get from here to key-and/or-value. Anyway, we're better off than before :-).