Skip to content

Commit

Permalink
Update experimental/union hash function measurement comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hsutter committed Jan 3, 2025
1 parent 26d85f1 commit 7beaeb4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ venv/*
buildh2.bat
gen_version.bat
mkdocs_serve.sh
experimental/a.out
12 changes: 7 additions & 5 deletions experimental/extrinsic_storage.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// *****************************************************************
// Enable/disable debug instrumentation and statistics printing here
constexpr auto debug_instrumentation = false;
constexpr auto debug_instrumentation = true;
// *****************************************************************


Expand Down Expand Up @@ -197,10 +197,12 @@ class extrinsic_storage {
) noexcept
-> Value*
{
auto hash = (((std::size_t)pobj)>>2) % Buckets;
// in my experiments, this has smoother utilization (only
// 6.6x difference between the most vs least popular bucket)
// than std::hash<void*>{}(pobj) % Buckets (22x difference)
//auto hash = std::hash<void*>{}(pobj) % Buckets; // A
auto hash = (((std::size_t)pobj)>>2) % Buckets; // B
// across the three major C++ implementations I tried, hash B has
// smoother utilization (2% to 5% difference between the most vs
// least popular bucket) than hash A (3.5% to 16% difference)

assert( 0 <= hash && hash < Buckets );
if constexpr (debug_instrumentation) {
// m_o_relaxed is enough, inc order doesn't matter for totals
Expand Down

0 comments on commit 7beaeb4

Please sign in to comment.