This is an archive of the discontinued LLVM Phabricator instance.

[Support] Change StringMap hash function from xxHash64 to xxh3_64bits
ClosedPublic

Authored by MaskRay on Jul 19 2023, 10:37 PM.

Details

Summary

Similar to D142862.

xxh3 is significantly faster than xxh64. Switch to xxh3, as we did for
for lld and llvm-dwarfutil to increase performance (D154813 D155675).
While I think StringMap is not a bottleneck for most applications, it
seems good to eliminate the slower xxh64. In addition, according to
D142862, Rust with a large constant string is sensitive to the StringMap
performance.

I have fixed all found issues separately, but one is remaining:

  • ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s has a failure due to StringMap iteration order. It now passes with LLVM_ENABLE_REVERSE_ITERATION=on while failing with LLVM_ENABLE_REVERSE_ITERATION=off.

Diff Detail

Event Timeline

MaskRay created this revision.Jul 19 2023, 10:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 10:37 PM
MaskRay requested review of this revision.Jul 19 2023, 10:37 PM
Herald added a project: Restricted Project. · View Herald TranscriptJul 19 2023, 10:37 PM

FYI, I ran this against the Rust compiler performance test suite and it didn't make a noticeable difference compared to the initial switch from DJB -> xxhash. (Which makes sense--DJB is so slow that it's hard to make an improvement that's anywhere close to that.)
It does seem to improve an artificial benchmark with very large constant strings by ~3% locally.

It of course still makes sense to do this, even if only to remove the old xxh64.

LGTM with the noted issues resolved.

FYI, I ran this against the Rust compiler performance test suite and it didn't make a noticeable difference compared to the initial switch from DJB -> xxhash. (Which makes sense--DJB is so slow that it's hard to make an improvement that's anywhere close to that.)
It does seem to improve an artificial benchmark with very large constant strings by ~3% locally.

Thank you for testing this patch! ~3% is still good.

It of course still makes sense to do this, even if only to remove the old xxh64.

Exactly, to make it clear that xxh64 is only for exceptions and only granted very carefully. Generally xxh3 should be used.

LGTM with the noted issues resolved.

I've managed to fix 10+ instances that relied on the iteration order. D155789 is now in place (tested by [[ https://lab.llvm.org/buildbot/#/builders/54 | a bot named reverse-iteration for llvm;clang;polly ]]) to prevent back sliding.
This patch is now as simple as changing just the StringMap code:)

This revision is now accepted and ready to land.Jul 22 2023, 8:09 AM
MaskRay updated this revision to Diff 543201.Jul 22 2023, 9:17 AM
MaskRay edited the summary of this revision. (Show Details)

flip the condition of llvm/test/ExecutionEngine/RuntimeDyld/ARM/MachO_ARM_PIC_relocations.s

This revision was landed with ongoing or failed builds.Jul 22 2023, 4:51 PM
This revision was automatically updated to reflect the committed changes.