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
Don't keep double vote information in blockNode #575
Don't keep double vote information in blockNode #575
Conversation
$ go test $(glide nv) -timeout 30m |
Profiles discovered that lookups into the signature cache included an expensive comparison to the stored `sigInfo` struct. This lookup had the potential to be more expensive than directly verifying the signature itself! In addition, evictions were rather expensive because they involved reading from /dev/urandom, or equivalent, for each eviction once the signature cache was full as well as potentially iterating over every item in the cache in the worst-case. To remedy this poor performance several changes have been made: * Change the lookup key to the fixed sized 32-byte signature hash * Perform a full equality check only if there is a cache hit which results in a significant speed up for both insertions and existence checks * Override entries in the case of a colliding hash on insert Add an * .IsEqual() method to the Signature and PublicKey types in the btcec package to facilitate easy equivalence testing * Allocate the signature cache map with the max number of entries in order to avoid unnecessary map re-sizes/allocations * Optimize evictions from the signature cache Delete the first entry * seen which is safe from manipulation due to the pre image resistance of the hash function * Double the default maximum number of entries within the signature cache due to the reduction in the size of a cache entry * With this eviction scheme, removals are effectively O(1) Fixes decred#575.
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.
OK
In order to keep the HF work as separate as possible, a new array was introduced in blockNode that keeps track of the version:bits tuple. With the HF work completed, we can now get rid of the voterVersion array and reuse the tuple in the stake version code.
This PR is purely mechanical.
Fixes #576