From 2ed641f710b8cbb5b18e8d76ce6cc9f6be799281 Mon Sep 17 00:00:00 2001 From: Georges Hatem Date: Sat, 27 Apr 2024 23:22:08 +0300 Subject: [PATCH 1/2] additional LEMIRE hash function --- entries/ghatem-fpc/src/OneBRCproj.lpi | 60 ++++++++++++++++++++++++++- entries/ghatem-fpc/src/onebrc.pas | 6 ++- 2 files changed, 64 insertions(+), 2 deletions(-) diff --git a/entries/ghatem-fpc/src/OneBRCproj.lpi b/entries/ghatem-fpc/src/OneBRCproj.lpi index 853c254..c19cbcd 100644 --- a/entries/ghatem-fpc/src/OneBRCproj.lpi +++ b/entries/ghatem-fpc/src/OneBRCproj.lpi @@ -15,7 +15,7 @@ - + @@ -137,6 +137,64 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/entries/ghatem-fpc/src/onebrc.pas b/entries/ghatem-fpc/src/onebrc.pas index 746c3db..d45e1b1 100644 --- a/entries/ghatem-fpc/src/onebrc.pas +++ b/entries/ghatem-fpc/src/onebrc.pas @@ -140,7 +140,11 @@ procedure TMyDictionary.InternalFind(const aKey: Cardinal; out aFound: Boolean; vDbl := aKey * cHashConst; vDbl := vDbl - Trunc (vDbl); vIdx := Trunc (vDbl * cDictSize); -{$ELSE} +{$ENDIF} +{$IFDEF LEMIRE} + vIdx := aKey * cDictSize shr 32; +{$ENDIF} +{$IFDEF HASHMOD} vIdx := aKey mod cDictSize; {$ENDIF} From c1857b3e9244a518dac25871cff0dc7bad788421 Mon Sep 17 00:00:00 2001 From: Georges Hatem Date: Sat, 27 Apr 2024 23:24:43 +0300 Subject: [PATCH 2/2] different configurations documentation --- entries/ghatem-fpc/README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/entries/ghatem-fpc/README.md b/entries/ghatem-fpc/README.md index 0cf1e53..02614d1 100644 --- a/entries/ghatem-fpc/README.md +++ b/entries/ghatem-fpc/README.md @@ -6,6 +6,11 @@ ## Usage - -t flag to specify the thread-count (default reads the thread-count available on the CPU) + +currently there are 3 configurations that can be compiled / run: + - `HASHMOD`: uses modulus for hashing, least collisions + - `HASHMULT`: alternative hashing, more collisions, faster on my PC, but seemingly slower on test PCs + - `LEMIRE`: faster hash function calculation, most collisions it seems, yet the fastest on my PC ## Hardware + Environment host: