From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!.POSTED.blaine.gmane.org!not-for-mail From: Stefan Monnier Newsgroups: gmane.emacs.bugs Subject: bug#25743: rehash-size ignored Date: Fri, 26 Jul 2019 13:16:10 -0400 Message-ID: References: <87tvb8lx38.fsf@mouse.gnus.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Injection-Info: blaine.gmane.org; posting-host="blaine.gmane.org:195.159.176.226"; logging-data="248747"; mail-complaints-to="usenet@blaine.gmane.org" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.0.50 (gnu/linux) Cc: 25743-done@debbugs.gnu.org To: Lars Ingebrigtsen Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Fri Jul 26 19:17:14 2019 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([209.51.188.17]) by blaine.gmane.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hr3qC-0012WD-54 for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Jul 2019 19:17:12 +0200 Original-Received: from localhost ([::1]:42006 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hr3q8-00049s-HV for geb-bug-gnu-emacs@m.gmane.org; Fri, 26 Jul 2019 13:17:08 -0400 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:39898) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hr3q4-00049f-SL for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2019 13:17:05 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hr3q2-0007VG-Oa for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2019 13:17:03 -0400 Original-Received: from debbugs.gnu.org ([209.51.188.43]:34491) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hr3q2-0007UY-IV for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2019 13:17:02 -0400 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1hr3q2-0000Mx-8i for bug-gnu-emacs@gnu.org; Fri, 26 Jul 2019 13:17:02 -0400 Resent-From: Stefan Monnier Original-Sender: "Debbugs-submit" Resent-To: bug-gnu-emacs@gnu.org Resent-Date: Fri, 26 Jul 2019 17:17:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: cc-closed 25743 X-GNU-PR-Package: emacs Mail-Followup-To: 25743@debbugs.gnu.org, monnier@iro.umontreal.ca, monnier@IRO.UMontreal.CA Original-Received: via spool by 25743-done@debbugs.gnu.org id=D25743.15641613821361 (code D ref 25743); Fri, 26 Jul 2019 17:17:01 +0000 Original-Received: (at 25743-done) by debbugs.gnu.org; 26 Jul 2019 17:16:22 +0000 Original-Received: from localhost ([127.0.0.1]:43310 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr3pO-0000Lt-FN for submit@debbugs.gnu.org; Fri, 26 Jul 2019 13:16:22 -0400 Original-Received: from mailscanner.iro.umontreal.ca ([132.204.25.50]:57837) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1hr3pM-0000Lf-0b for 25743-done@debbugs.gnu.org; Fri, 26 Jul 2019 13:16:20 -0400 Original-Received: from pmg1.iro.umontreal.ca (localhost.localdomain [127.0.0.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id 6C656102D83; Fri, 26 Jul 2019 13:16:14 -0400 (EDT) Original-Received: from mail01.iro.umontreal.ca (unknown [172.31.2.1]) by pmg1.iro.umontreal.ca (Proxmox) with ESMTP id CD94E1013C1; Fri, 26 Jul 2019 13:16:12 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=iro.umontreal.ca; s=mail; t=1564161372; bh=aKIRg8ltqDPjjoZsmQ/XOJqHopXfnQ2ftlNfIV7oI7E=; h=From:To:Cc:Subject:References:Date:In-Reply-To:From; b=aURjxS/zbMu/0hyqsn85PSTb+9KnBCFLA9QVhcDwP1g0cGDfkev5khlUh8xsMQ0rb HgvrdV0MVTc4s/NLf0oSQFnILkLhA72tWcBCGRmmlVZsJTcjioGyQDUKkjzgzWKu/F Dkgo81BpEG1R0ArPQPAOzSnGgKtP95s+zLo+9ZIiILZ3CwWMvBr2EM7DF426XRLFxv fMf4HrZMl5ubpioltbypzXhPzF1fvtyG05e4HMVL1eB6vFfXQxgc4QIUYuR4fVeDri HYX5YocF5boCRFh2DimvLjEiS0O7qOGwNo19HvBnUbXb8IL4Mdztt0ZgT47cZU5Nqc XCO2QVn6+rrMw== Original-Received: from alfajor (modemcable157.163-203-24.mc.videotron.ca [24.203.163.157]) by mail01.iro.umontreal.ca (Postfix) with ESMTPSA id 9A8AD120C2D; Fri, 26 Jul 2019 13:16:12 -0400 (EDT) In-Reply-To: <87tvb8lx38.fsf@mouse.gnus.org> (Lars Ingebrigtsen's message of "Fri, 26 Jul 2019 15:55:07 +0200") X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.51.188.43 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.org@gnu.org Original-Sender: "bug-gnu-emacs" Xref: news.gmane.org gmane.emacs.bugs:163808 Archived-At: > * src/fns.c (maybe_resize_hash_table): Completely initialize the > new =E2=80=98next=E2=80=99 vector before allocating more vectors, as = this > preserves locality a bit better and it=E2=80=99s safer not to leave an > uninitialized Lisp object around. Use next_size instead of > new_size to compute new index size. > > So is the issue discussed in this bug report fixed now? This patch fixes the most severe problem (which was that the table was larger than requested and we didn't take it into account in the rest of the code). But it doesn't fix the problem in the title: by default rehash-size is 1.5 yet in practice the code just doubles the size (because larger_vecalloc only allocates something smaller than twice the original size when we're reaching the maximum possible size). So I installed the patch below to finish it. Thanks, Stefan diff --git a/src/fns.c b/src/fns.c index f4f3b95ac6..c45f455646 100644 --- a/src/fns.c +++ b/src/fns.c @@ -4190,7 +4190,7 @@ maybe_resize_hash_table (struct Lisp_Hash_Table *h) avoid problems if memory is exhausted. larger_vecalloc finishes computing the size of the replacement vectors. */ Lisp_Object next =3D larger_vecalloc (h->next, new_size - old_size, - PTRDIFF_MAX / 2); + new_size); ptrdiff_t next_size =3D ASIZE (next); for (ptrdiff_t i =3D old_size; i < next_size - 1; i++) gc_aset (next, i, make_fixnum (i + 1));