From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Newsgroups: gmane.emacs.bugs Subject: bug#68244: hash-table improvements Date: Mon, 12 Feb 2024 13:16:44 +0100 Message-ID: References: <170438379722.3921.9312235725296561206@vcs2.savannah.gnu.org> <20240104155642.B4A99C00344@vcs2.savannah.gnu.org> <8d49ebdc-9da7-4e70-a080-d8e892b980b6@gutov.dev> <08314177-5AE9-4352-94A0-641830B4094D@gmail.com> <19265EA5-E6F3-446C-AD9B-763693CF0A48@gmail.com> <6F3E332D-54ED-4E70-BBAA-A207750B52F8@gmail.com> Mime-Version: 1.0 (Mac OS X Mail 14.0 \(3654.120.0.1.15\)) Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="21782"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Gerd =?UTF-8?Q?M=C3=B6llmann?= , Dmitry Gutov , Eli Zaretskii , 68244@debbugs.gnu.org, Stefan Kangas To: Stefan Monnier Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Mon Feb 12 13:26:09 2024 Return-path: Envelope-to: geb-bug-gnu-emacs@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 1rZVNw-0005VD-HF for geb-bug-gnu-emacs@m.gmane-mx.org; Mon, 12 Feb 2024 13:26:08 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rZVNg-0004Yk-KL; Mon, 12 Feb 2024 07:25:52 -0500 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 1rZVNa-0004YG-M7 for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 07:25:47 -0500 Original-Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rZVNZ-00037c-RF for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 07:25:46 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rZVNq-0006Pj-H4 for bug-gnu-emacs@gnu.org; Mon, 12 Feb 2024 07:26:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Mattias =?UTF-8?Q?Engdeg=C3=A5rd?= Original-Sender: "Debbugs-submit" Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 12 Feb 2024 12:26:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 68244 X-GNU-PR-Package: emacs Original-Received: via spool by 68244-submit@debbugs.gnu.org id=B68244.170774071824436 (code B ref 68244); Mon, 12 Feb 2024 12:26:02 +0000 Original-Received: (at 68244) by debbugs.gnu.org; 12 Feb 2024 12:25:18 +0000 Original-Received: from localhost ([127.0.0.1]:53415 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZVN7-0006M2-M9 for submit@debbugs.gnu.org; Mon, 12 Feb 2024 07:25:18 -0500 Original-Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]:56698) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rZVFG-0005m2-TG for 68244@debbugs.gnu.org; Mon, 12 Feb 2024 07:17:11 -0500 Original-Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-51147d0abd1so3364879e87.1 for <68244@debbugs.gnu.org>; Mon, 12 Feb 2024 04:16:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707740207; x=1708345007; darn=debbugs.gnu.org; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:from:to:cc:subject :date:message-id:reply-to; bh=AbSuuvwZukSH4O31Tr+LR72fvtEexsiiHGRhB28vH9I=; b=hOG9ig22dKNAd08QZG9Rkt8mAYeq3jkpIqNoHjGhn9PGIeTddYFdrHmtSO7dsvqmNd 6ZoDrM8AUz/SCmCFSBRySat7E6pWeUXzNoO85fiML+8jUJeo6A3wZrkpREUsPK9x0jOt IRgWnn0eHmBTTgNQipMUqTxC86WaYEJjbpzZFFJT0mDLUjQJR2lytFxQm4ivw24jBa2+ sZdPwx5KfIIFP3HQwIV7Q1zmEC48M6coMuurojAQY4ouihQ4iDXB5lzgHGrDe9wiMyAa l/YYVC5k5ZMkBKHzw4nhIHU+zY6/2+8HWRfGfajfQs6Jiri5SY/6nLmVFDklDqn9sVSa fSIQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707740207; x=1708345007; h=to:references:message-id:content-transfer-encoding:cc:date :in-reply-to:from:subject:mime-version:sender:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=AbSuuvwZukSH4O31Tr+LR72fvtEexsiiHGRhB28vH9I=; b=QNl9k5aD/0TQRtN8fSzlaEiqs2GKoAhsEs2+4GHfLc4S6wSwqC+a5LFABITPCwxBY5 rUSR2/hdct+5ueAYMjIo6l1OJ1JVsnsJluwETsP1YJ/6fKIWEosl6FqQP0O/wMm/KIUF VHmWEHlpZdicIK9o7CjfFpbnmXAoqCu5Uw6GDOIRlHGSmS9Js4E3LMY5mLGvnfUQ1i7m aVj9EglGGIemhLT+WBOmw3v7opo27fFP5HF0Ov4xY/8h4uDOzmAOo5bxKuhTxNPaaQ1e 6NMxhz77v+zHT3jGWXwFhsx7Z/gmfjdBPMTJNVPxQb8xtIHvlKUinjUb6YjVlbs0xrHP VFrQ== X-Forwarded-Encrypted: i=1; AJvYcCWKnhQa3+Z3AAYTUL2j0T2x3a5L9H7RcPyfsiq0t7c8ykTEl+I/RyymN9sBNGVahAU1IDfiA0bsAkt8n3xSdNbPFlScFDU= X-Gm-Message-State: AOJu0Yx+TN3mMUHY29nJQrn1o3wd9K8AxFboDFVScFEIRvyHxeSKIRPH z4fsmJ9zcjwDp7zUnAr7rI9jfXeel2bVKBo+qGz6/v3R7JJlt9Zi X-Google-Smtp-Source: AGHT+IE4bTn2wnxeX/AmU2DLfdSWLvl8MZowEm8ZLUMF07UeemMomsdI156Ow6G3kDDm0RTNDp+iCQ== X-Received: by 2002:a19:7506:0:b0:511:3232:954f with SMTP id y6-20020a197506000000b005113232954fmr4303686lfe.2.1707740207133; Mon, 12 Feb 2024 04:16:47 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCW7AUTrU3n75W7tUxm7Vj9jscl3AnrX6CNwf/idtuhF4+WUYqFPt2tM9ZPACrSGLDU0IzIjKh/2sPsZwC9w2UgGxqwV55SGHPwP+VT6ExR/zvHbyguoeiIykajd23X0+QmfXVf6fY3MEKTHHOnQ/O4m0wyiV1ugIZnTBsBiacwlXIEb1j+T Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id fb13-20020a056512124d00b005118d5b3adbsm416862lfb.98.2024.02.12.04.16.45 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 12 Feb 2024 04:16:46 -0800 (PST) In-Reply-To: X-Mailer: Apple Mail (2.3654.120.0.1.15) X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list 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-mx.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Xref: news.gmane.io gmane.emacs.bugs:279889 Archived-At: 8 feb. 2024 kl. 18.49 skrev Stefan Monnier : >> And you are right about the need for vector compatibility, just = discovered >> that the hard way. >=20 > Welcome to the club :-) And to show that I'm repeating all your mistakes and ignoring your = hard-won wisdom, I made a patch for PVEC_OBARRAY. * It does give a nice speed-up, not only in microbenchmarks. Relint on = the Emacs directory tree sees a speed-up of 5 % which is not bad = considering how much work that code does. * Contrary to your suggestion I went with an entirely new type, which = means that: - obarray objects grow automatically and use the same faster hashing = (Knuth) as hash tables - `obarrayp` is now true for both obarray objects and vectors; = `obarray-object-p` detects the new type only. - `obarray-make` now produces an obarray object. - All old built-in functions that take an obarray now accept both = vectors and obarray objects - New function `obarray-clear` to replace code that filled vectors with = 0 * Compatibility with existing code is excellent except for some places = that used `obarray-make` but then assumed the result to be vectors = (using `vectorp` instead of `obarrayp` etc). Your suggestion to represent obarrays as a single-element vector = containing an actual object (PVEC_OBARRAY or a hash table) would kind of = help here but it still seems like a half-measure and perpetuates some = problems that we would like to avoid with a new type. Maybe a different kind of compromise would be better: `obarray-make` is = kept unchanged as make-vector (but deprecated), and a new `make-obarray` = (for example) creates the new objects. Oh, and there is a small glitch in the existing code: when a symbol is = uninterned, its status is set to SYMBOL_UNINTERNED, but if its = containing obarray is GCed away or manually cleared then this doesn't = happen. This is probably not worth fixing but at least with PVEC_OBARRAY = we could if we wanted to.