This is an archive of the discontinued LLVM Phabricator instance.

Use the default seed value for djb hash for StringMap
ClosedPublic

Authored by serge-sans-paille on Feb 24 2021, 9:15 AM.

Details

Summary

See original comment in 560ce2c70fb1fe8e4b9b5e39c54e494a50373ba8
Basically the default seed value results in less collision, but changes the
iteration order, which matters for a few test cases.

The performance gain was worth doing the test update.

Diff Detail

Event Timeline

serge-sans-paille requested review of this revision.Feb 24 2021, 9:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 24 2021, 9:15 AM

The performance gain was worth doing the test update.

How did you measure this and what were the results?

The performance gain was worth doing the test update.

How did you measure this and what were the results?

I ran the following before / after the patch:

curl -L -O https://github.com/azadkuh/sqlite-amalgamation/raw/master/sqlite3.c
perf stat -e instructions clang -O0 -c sqlite3.c -o/dev/null -w

And compared the instruction count reported. This is similar to the approach taken by http://llvm-compile-time-tracker.com/ and confirms the literature about the default seed for that hashing function.

Before the patch: 6,139,868,068 instructions
After the patch: 6,137,774,225 instructions

LG. The compiler may spend a lot of time in common data structures like DenseMap. It is possible that some contributors may want to optimize the data structures. It'd be nice if tools have less reliance on the iteration order, even if they are stable on 32-bit and 64-bit machines. The test updates suggest to me that llvm-dwarfdump may need a fix.

JDevlieghere accepted this revision.Feb 25 2021, 6:39 PM

The performance gain was worth doing the test update.

How did you measure this and what were the results?

I ran the following before / after the patch:

curl -L -O https://github.com/azadkuh/sqlite-amalgamation/raw/master/sqlite3.c
perf stat -e instructions clang -O0 -c sqlite3.c -o/dev/null -w

And compared the instruction count reported. This is similar to the approach taken by http://llvm-compile-time-tracker.com/ and confirms the literature about the default seed for that hashing function.

Before the patch: 6,139,868,068 instructions
After the patch: 6,137,774,225 instructions

Thanks!

It'd be nice if tools have less reliance on the iteration order, even if they are stable on 32-bit and 64-bit machines. The test updates suggest to me that llvm-dwarfdump may need a fix.

+1

LGTM

This revision is now accepted and ready to land.Feb 25 2021, 6:39 PM
MaskRay accepted this revision.Feb 25 2021, 7:42 PM
This revision was landed with ongoing or failed builds.Mar 1 2021, 4:21 AM
This revision was automatically updated to reflect the committed changes.