-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Make FNV hash compatible across endianness #9489
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
FYI: @KalleOlaviNiemitalo, @uweigand - thank you for all the input! |
|
What runtime were those results from? I'd expect |
|
Ah - I forgot to mention that - good point! Yes - those were for NET 8.0 only. 3.5 need to use the 'compatible' version anyways. The 4.7.2 can use the Span version, but it as well perform slightly worse (overall the numbers were quite similar - |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for following through!
|
Since the compatible version seems to be faster anyway, this change seems reasonable, but what does that have to do with endianness? It seems like the span version and the not-span version do the same thing... |
Casting byte ptr to char ptr leads to proper reordering of bytes (if needed) in memory by runtime (so that they are Little Endian, regardless of the actual storage arch) #9387 (comment) has more details |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Thanks for the explanation! Sorry I didn't follow that link before 🙂 Looks like there's a conflict. |
|
We also have an Fnv1a implementation in the binlog writer: msbuild/src/Build/Logging/BinaryLogger/BuildEventArgsWriter.cs Lines 1314 to 1342 in 10f2f32
See my analysis here: Would be interesting to add this hash implementation to my benchmarks and compare: |
Yeah - I 'borrowed' that one ( Other than the Note though that currently this work is on waiting banch till the #9572 is fixed. |
|
Blocking issue in CPS. |
|
Superseded by #9721 |
Context
#9387 (comment)
Current FNV hashing (introduced in #9387) is dependent on endian-ness.
Changes Made
Removed the span version of hashing - as it doesn't bring any benefits and is endian-ness dependent
Perf testing
(".NET Framework 4.7.2" shortened to ".NET 4.7.2" for the content brevity)
The test harness: