-
Notifications
You must be signed in to change notification settings - Fork 441
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
Memoize Keccaks #7333
Memoize Keccaks #7333
Conversation
{ | ||
internal readonly byte[] _bytes = bytes; | ||
public static implicit operator BytesWrapper(byte[] bytes) => new(bytes); | ||
public static implicit operator BytesWrapper(ReadOnlySpan<byte> bytes) => new(bytes.ToArray()); |
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.
Can we search by Span without allocating first, like in SpanDictionary?
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.
Not in the regular ConcurrentDictionary; though it should live an die pretty fast in Gen0.
Also another reason to limiting to 32 bytes
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.
Well it is good I made SpanConcurrentDictionary ]:->
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.
Would be great to use SpanDictionary in the cache (maybe have a derived type? And avoid allocating when searching in cache.
Will throw that for comaprision with master on same spec |
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.
Minor remarks while working on a different approach.
{ | ||
private const int CacheCount = 256; | ||
private const int CacheMax = CacheCount - 1; | ||
private readonly ClockCache<BytesWrapper, ValueHash256>[] _caches; |
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.
Quite a lot of objects here 😢
Closing in favour of #7336 |
Follow up to #7328
Changes
Types of changes
What types of changes does your code introduce?
Testing
Requires testing