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: Fri, 5 Jan 2024 11:33:52 +0100 Message-ID: <08314177-5AE9-4352-94A0-641830B4094D@gmail.com> References: <170438379722.3921.9312235725296561206@vcs2.savannah.gnu.org> <20240104155642.B4A99C00344@vcs2.savannah.gnu.org> <8d49ebdc-9da7-4e70-a080-d8e892b980b6@gutov.dev> 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="37420"; mail-complaints-to="usenet@ciao.gmane.io" Cc: Eli Zaretskii , 68244@debbugs.gnu.org, Stefan Monnier To: Dmitry Gutov Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane-mx.org@gnu.org Fri Jan 05 11:35:22 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 1rLhXt-0009Ui-L7 for geb-bug-gnu-emacs@m.gmane-mx.org; Fri, 05 Jan 2024 11:35:21 +0100 Original-Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rLhXY-0007K2-Mp; Fri, 05 Jan 2024 05:35:00 -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 1rLhXW-0007Iw-Qo for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 05:34:58 -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 1rLhXW-0002ps-I4 for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 05:34:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1rLhXa-0007RR-GA for bug-gnu-emacs@gnu.org; Fri, 05 Jan 2024 05:35: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: Fri, 05 Jan 2024 10:35: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.170445086328553 (code B ref 68244); Fri, 05 Jan 2024 10:35:02 +0000 Original-Received: (at 68244) by debbugs.gnu.org; 5 Jan 2024 10:34:23 +0000 Original-Received: from localhost ([127.0.0.1]:56433 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLhWi-0007QE-MY for submit@debbugs.gnu.org; Fri, 05 Jan 2024 05:34:23 -0500 Original-Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]:56648) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1rLhWf-0007Pi-Bj for 68244@debbugs.gnu.org; Fri, 05 Jan 2024 05:34:07 -0500 Original-Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2cd0d05838fso16559021fa.1 for <68244@debbugs.gnu.org>; Fri, 05 Jan 2024 02:34:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1704450835; x=1705055635; 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=4Yx5jhAC8dbdAaJbRf0DVawBL1Rru4imF2Z3E3Tjw7s=; b=dR3CU0MxJRlF7KaVNYZdk7Pqp/FKYeRcBICe8Uvx7vh/bu9y7ErUywK7I7C7Jh7HPC VWxQEvrczNn8Ne3ilt0T1tEh96GSkrgQNq9TIRFll9DWpCDmjlVlv3HiA2dNFbnCwTmw mUaHCoRs38XBmbh4g7DRyvBm8oi+ORG1ONxVdMbx8KCZCmY2+ZtG+0+WEpZ+fhaIt/Yh HvOABasH/WS1sMZOwlJBtiiKA/+Lp3bddwjILzlSYvwQrMs3zM85Ix37An2fnG/hgAZh F8xzEMhh/gk06SOSkc4znJWLLFvlFhUKO0w7pmYACuFqShPKkAkpifChd6vhpYTM/Gy3 QPFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1704450835; x=1705055635; 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=4Yx5jhAC8dbdAaJbRf0DVawBL1Rru4imF2Z3E3Tjw7s=; b=aYp2FxGbaGTC3clSM7Gea1GtU2I0iwTEUFIaD9720XJeBvJfVpwBhdt5RgeRV69YT+ 3dVvJjr8EEFsM1d34H9UElguEVClzK++19vAWsyQaJxj6skUcRULIMdETegTzSYW6Gtv VCY5eDqWFONqre9vx5BcQ2PC0KaUI5SJGgkd+phX28w1IOlc0ba3s3KS/ATAzoLv9GLB Yx76GZ/U+3SkEXz5wV1TPjf4X0Hqqxvrs+yQWzGhViqFYTjo0AB+orD0Zp395wa1x05P IC1TC0xWeUFTU27bCnXuq2Hcgpsrd6zo4tQ3e7v+QbtAphKcq+gdYLro2tGnw1LxuHrR HDTQ== X-Gm-Message-State: AOJu0YxujfTQlK4URDdcdvgK0KLo2nZGLEmoqstyCp7B1U3D5I8foD3Y D4z68OpuFsa6d8BciM4pCPEBXrtvb0Y= X-Google-Smtp-Source: AGHT+IHQCLtEdIAsLeo3WT/OfOPxseNRbSO8vHsO2pZUgxHyK8Bc2sBT+X+wCy+kofVa82y7vvzaMQ== X-Received: by 2002:a05:6512:b12:b0:50e:9c17:24d2 with SMTP id w18-20020a0565120b1200b0050e9c1724d2mr1252413lfu.18.1704450834643; Fri, 05 Jan 2024 02:33:54 -0800 (PST) Original-Received: from smtpclient.apple (c80-217-1-132.bredband.tele2.se. [80.217.1.132]) by smtp.gmail.com with ESMTPSA id s17-20020a056512215100b0050e77b1f0c7sm202903lfr.117.2024.01.05.02.33.53 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Jan 2024 02:33:53 -0800 (PST) In-Reply-To: <8d49ebdc-9da7-4e70-a080-d8e892b980b6@gutov.dev> 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:277377 Archived-At: [ replies to questions asked elsewhere ] 4 jan. 2024 kl. 18.32 skrev Dmitry Gutov : >> +hash_table_alloc_bytes (ptrdiff_t nbytes) >> +{ >> + if (nbytes =3D=3D 0) >> + return NULL; >> + tally_consing (nbytes); >> + return xmalloc (nbytes); >> +} >=20 > Sorry if it's a stupid question, but if the operation doesn't add any = Lisp "garbage", why increase the consing counter? That is likely = triggers more GCs earlier which otherwise might not run, and if there = are no slots to GC, it seems like they would run in vain. That's a good question and it all comes down to how we interpret = `consing_until_gc`. Here we take the view that it should encompass all = parts of an allocation and this seems to be consistent with existing = code. These ancillary allocations are parts of the hash-table object: they are = allocated and freed at the same time as the mother object, and subject = to the same `consing_until_gc` accounting. The new code is radically more efficient when growing tables, because we = can free the old vectors immediately (and adjust consing_until_gc = accordingly) instead of leaving it as garbage waiting to be collected. = This provides several benefits in itself (GCs are made less often, we = can re-use hot memory). Not having to traverse them in either the mark = or sweep phases is another big gain (the key_and_value parts still have = to be marked, of course). > I'm curious whether any of these callers have tested with different = values and found a difference in performance: >=20 > = https://github.com/search?q=3D%3Arehash-threshold+language%3A%22Emacs+Lisp= %22&type=3Dcode&l=3DEmacs+Lisp I don't think they did, but it's easy to picture what was going on: Manual: Here is a Knob. It can be Turned to improve Performance. User: Knob! Performance! Some trials indicate that it's almost impossible for a user to use those = knobs effectively, nor should they have to. Moreover, by removing them = we not only give users fewer things to worry about, we are also able to = improve performance for everyone.