Re: Compilation issues for HASH_STATISTICS and HASH_DEBUG options
Michael Paquier <michael@paquier.xyz>
From: Michael Paquier <michael@paquier.xyz>
To: David Rowley <dgrowleyml@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>, "Hayato Kuroda (Fujitsu)" <kuroda.hayato@fujitsu.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2025-08-17T06:54:16Z
Lists: pgsql-hackers
On Sun, Aug 17, 2025 at 12:24:29AM +1200, David Rowley wrote: > I noticed that the existing code has a set of global variables that > keeps track of accesses, collisions and expansions for *all* tables in > the backend. This didn't fit well with the single line elog. I kinda > though the global information was a bit strange, so I just got rid of > it. There was no "expansions" field to track the number of expansions > for a single table, so I added one. I made all these uint64. I felt > long (which can be 32-bit on some platforms) was too small for > tracking the number of hash table accesses. Likely uint64 is too wide > to track the expansions. That likely could be made smaller, but since > these are not enabled by default, they're not taking up any struct > space in normal builds. -#ifdef HASH_STATISTICS -static long hash_accesses, - hash_collisions, - hash_expansions; -#endif These global counters are as old as d31084e9d111. Removing them should not be a problem. Using DEBUG4 looks sensible here for this purpose. Side thing.. I'm wondering what prevents us from wiping out entirely the use of long in this file. long is 8 bytes everywhere, except on WIN32 where it's 4 bytes (as you say), which is a bad practice as we have been bitten by overflows because of this dependency in the patch. Not related to this patch, still seems worth cleaning up while looking at this code. There are a few more things like HASHCTL, of course.. -- Michael
Commits
-
Remove HASH_DEBUG output from dynahash.c
- a98ccf727ebb 19 (unreleased) landed
-
Use elog(DEBUG4) for dynahash.c statistics output
- 05fcb9667c37 19 (unreleased) landed
-
Fix invalid format string in HASH_DEBUG code
- 2c7c08a090f2 14.20 landed
- 199a347d29e5 15.15 landed
- d809494cdfc5 16.11 landed
- 04b384b3efb2 17.7 landed
- 1571c7ca5dc9 18.0 landed
- 296cba276081 19 (unreleased) landed
-
Fix failing -D HASH_STATISTICS builds
- efe705b05cc1 17.7 landed
- e4ba326295c5 18.0 landed
- ca38912512a9 19 (unreleased) landed
-
Refactor initial hash lookup in dynahash.c
- cc5ef90edd80 17.0 cited
-
Remove large fill factor support from dynahash.c.
- be0a6666656e 14.0 cited
-
Remove broken and useless entry-count printing in HASH_DEBUG code.
- 9d4e56699957 10.0 cited
-
Partition the freelist for shared dynahash tables.
- 44ca4022f3f9 9.6.0 cited