From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.io!.POSTED.blaine.gmane.org!not-for-mail From: Newsgroups: gmane.emacs.devel Subject: Re: Wondering about FACE_CACHE_BUCKETS_SIZE Date: Wed, 10 Feb 2021 10:08:35 +0100 Message-ID: <20210210090835.GA17142@tuxteam.de> References: <673E9F11-29F6-4F5B-B754-34FD9776DDB6@acm.org> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="nFreZHaLTZJo0R7j" Injection-Info: ciao.gmane.io; posting-host="blaine.gmane.org:116.202.254.214"; logging-data="10763"; mail-complaints-to="usenet@ciao.gmane.io" User-Agent: Mutt/1.5.21 (2010-09-15) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane-mx.org@gnu.org Wed Feb 10 10:12:02 2021 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 1l9lXU-0002aW-Q9 for ged-emacs-devel@m.gmane-mx.org; Wed, 10 Feb 2021 10:12:00 +0100 Original-Received: from localhost ([::1]:59674 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l9lXT-00079D-Is for ged-emacs-devel@m.gmane-mx.org; Wed, 10 Feb 2021 04:11:59 -0500 Original-Received: from eggs.gnu.org ([2001:470:142:3::10]:52672) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l9lUP-0005g6-Oq for emacs-devel@gnu.org; Wed, 10 Feb 2021 04:08:49 -0500 Original-Received: from mail.tuxteam.de ([5.199.139.25]:55799) by eggs.gnu.org with esmtps (TLS1.2:DHE_RSA_AES_128_CBC_SHA1:128) (Exim 4.90_1) (envelope-from ) id 1l9lUK-00041G-8V for emacs-devel@gnu.org; Wed, 10 Feb 2021 04:08:49 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=tuxteam.de; s=mail; h=From:In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:To:Date; bh=qbumf61Biw1d0a+tX8SLypmTWUHj+TlhP69oxzOFTrw=; b=NHqxajrHHkA8EopGoQx84B0wF/ci0dhpAOpLCjOiqzcC1l6bJsYc8s6AFVGZjBYYpBSG47dWiO9cj4h9rojrvkdftm1uLDfoSMdR62Kcm6WRGfOL9ae2IEswRJVJPnMjHj6lz1/jkHwLPH0I+LXnXqg7GVKNc25s0vRyR4LgW8VOeoXB8FWKeb+50K2owMEw+hy2YsZOOwCUMj4kTeL4TE8mqEnPuLJKe42b+OUvAxJvoJKzCuWsr9ECeMmVu/5MzDyYWQZcnj62Kg46PjJVIuhdhC3xAM9GyVaMjBw7gv/bE2yVFmDRmiwvqis0V4d8KwmP+keDLJFhSZ5f53BPVw==; Original-Received: from tomas by mail.tuxteam.de with local (Exim 4.80) (envelope-from ) id 1l9lUC-0004gV-01 for emacs-devel@gnu.org; Wed, 10 Feb 2021 10:08:36 +0100 Content-Disposition: inline In-Reply-To: <673E9F11-29F6-4F5B-B754-34FD9776DDB6@acm.org> Received-SPF: pass client-ip=5.199.139.25; envelope-from=tomas@tuxteam.de; helo=mail.tuxteam.de 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, 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.23 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" Xref: news.gmane.io gmane.emacs.devel:264264 Archived-At: --nFreZHaLTZJo0R7j Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Tue, Feb 09, 2021 at 09:53:34PM -0500, Win Treese wrote: >=20 > I happened to be looking at some code in src/xfaces.c on the trunk, and I > noticed this at lines 289-292: >=20 > /* Size of hash table of realized faces in face caches (should be a > prime number). */ >=20 > #define FACE_CACHE_BUCKETS_SIZE 1001 >=20 > 1001 isn=E2=80=99t prime (it=E2=80=99s 7*11*13). No, it isn't :-) > A quick look at the hash table code > suggest that the main effect of it is to slow things down a little bit > because some hash buckets would get used more often than they > would be with a prime.=20 Still, this is pretty improbable. This would mean that whatever is hashed in that table shows some statistical correlation with one of the linear sequences m + n*i for n in {7, 11, 13}. Would be surprising, at least. For some even (possibly power-of-two) numbers, I'd be more willing to bet on it. Say you're hashing pointers: for alignment reasons they are all divisible by 4, or 8. I'd venture to say "prime enough", although 7 is uncomfortably small a divisor ;-) > From the git log, it=E2=80=99s been this way since the code was first com= mitted > in 1999. >=20 > There=E2=80=99s probably no real problem here, except that the comment and > code don=E2=80=99t match. On the other hand, 997 and 1009 are nice nearby > primes if it really matters. But yes, to be in the camp "there will be no clustering, even if an enemy choses the keys", perhaps 991, 997 or 1009 are better choices. Cheers - t --nFreZHaLTZJo0R7j Content-Type: application/pgp-signature; name="signature.asc" Content-Description: Digital signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) iEYEARECAAYFAmAjopMACgkQBcgs9XrR2kb2bgCfY5S8TSrDBYLQWMroUlSTQzXk dyMAn0tGSTZsmF18Wt5n+qBiCyBcdlXm =mZEQ -----END PGP SIGNATURE----- --nFreZHaLTZJo0R7j--