Make FNV hash compatible across endianness - #9489
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 - |
ladipro
left a comment
There was a problem hiding this comment.
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 |
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: