Skip to content
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

Fast Keccak cache (wait-free and lockless) #7336

Merged
merged 53 commits into from
Sep 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
53 commits
Select commit Hold shift + click to select a range
280097e
More comments
Scooletz Aug 16, 2024
7ecd7a5
comments
Scooletz Aug 16, 2024
8dce0c7
updated
Scooletz Aug 16, 2024
dec33ca
EVM uses the cached keccak
Scooletz Aug 16, 2024
f5b756c
state tree
Scooletz Aug 16, 2024
df510fd
more tests
Scooletz Aug 16, 2024
154037e
special cases
Scooletz Aug 16, 2024
24a595b
Release with Volatile.Write
Scooletz Aug 16, 2024
790f86d
StorageTree added
Scooletz Aug 16, 2024
2593734
comments
Scooletz Aug 16, 2024
805e28c
one less CAS
Scooletz Aug 16, 2024
b01d503
more go-tos
Scooletz Aug 16, 2024
83e8489
Merge branch 'master' into keccak-cache
benaadams Aug 16, 2024
0118c1d
one less branch in hash
Scooletz Aug 16, 2024
af55085
Merge branch 'keccak-cache' of https://github.com/NethermindEth/nethe…
Scooletz Aug 16, 2024
21d7714
Merge branch 'master' into keccak-cache
benaadams Aug 16, 2024
2e74b76
Start with per instance random
benaadams Aug 16, 2024
a29dcec
Include length in hash seed
benaadams Aug 16, 2024
e654d13
Improve comment
benaadams Aug 16, 2024
c88d931
Move stackalloc out of common path and inline ComputeKey to it
benaadams Aug 17, 2024
6fcfb9a
Unify hashing
benaadams Aug 17, 2024
381511e
Use full hash
benaadams Aug 18, 2024
9e2ea27
Faster StorageCell equality
benaadams Aug 18, 2024
c3996a2
Less copy
benaadams Aug 18, 2024
669cec4
Merge branch 'master' into keccak-cache
benaadams Aug 18, 2024
d1483ce
Even less copy
benaadams Aug 18, 2024
2070cc2
Doesn't need to return
benaadams Aug 19, 2024
28e0fa4
Update alignment comments
benaadams Aug 19, 2024
89bd655
lol; don't do extra work
benaadams Aug 19, 2024
42ef8f6
Faster compares
benaadams Aug 19, 2024
773ef2a
Move other HasCodes to FastHash
benaadams Aug 19, 2024
226be3f
Special case 32 and 20 bytes hashes
benaadams Aug 19, 2024
7d5fba5
Word align vector compare
benaadams Aug 19, 2024
7184d26
constants
Scooletz Aug 19, 2024
795b4c9
stack reduced by 8 and one less comparison on read
Scooletz Aug 19, 2024
c19edb3
Use full entropy of HashCode for comparision
benaadams Aug 19, 2024
1f8b94f
Revert "Use full entropy of HashCode for comparision"
benaadams Aug 19, 2024
928929e
Tweaks
benaadams Aug 19, 2024
e32f995
comments
Scooletz Aug 19, 2024
6938aab
Align 32
benaadams Aug 19, 2024
545384f
Merge branch 'keccak-cache' of https://github.com/NethermindEth/nethe…
benaadams Aug 19, 2024
472ca26
smaller entry, bigger cache
Scooletz Aug 20, 2024
7d1bba6
Missed one
benaadams Aug 20, 2024
b8a6f7f
Merge branch 'master' into keccak-cache
benaadams Aug 20, 2024
9e8b635
Merge branch 'master' into keccak-cache
benaadams Aug 23, 2024
a536245
Merge branch 'master' into keccak-cache
benaadams Aug 31, 2024
50c1e8f
Faster FastHash
benaadams Aug 31, 2024
fc52fcc
alignment handled with if
Scooletz Sep 2, 2024
c11cc94
Merge branch 'master' into keccak-cache
benaadams Sep 11, 2024
ce44b4c
Merge branch 'master' into keccak-cache
benaadams Sep 11, 2024
a2a0155
Merge branch 'master' into keccak-cache
benaadams Sep 19, 2024
7363f2c
Missed one fastHash
benaadams Sep 19, 2024
70f5995
Add memory pressure
benaadams Sep 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/Nethermind/Nethermind.Core/Crypto/KeccakCache.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ namespace Nethermind.Core.Crypto;
/// </summary>
public static unsafe class KeccakCache
{
private static readonly uint s_instanceRandom = (uint)System.Security.Cryptography.RandomNumberGenerator.GetInt32(int.MinValue, int.MaxValue);
benaadams marked this conversation as resolved.
Show resolved Hide resolved
/// <summary>
/// Count is defined as a +1 over bucket mask. In the future, just change the mask as the main parameter.
/// </summary>
Expand Down Expand Up @@ -130,7 +131,7 @@ private static uint FastHash(ReadOnlySpan<byte> input)
ref var b = ref MemoryMarshal.GetReference(input);

// Start with first
uint hash = b;
uint hash = s_instanceRandom ^ b;

// This is done below, without branches
// if ((length & 1) == 1)
Expand Down