-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
Make sigcache faster, more efficient, larger #6918
Conversation
sipa
commented
Oct 30, 2015
- Changes the -maxsigcachesize argument from entries to megabytes
- Change the default to 40 MiB (as opposed to ~10 MiB before), corresponding to over 500000 entries on 64-bit systems.
- Store salted SHA256 hashes in the cache, rather than full entries.
- Switch implementation from std::set to boost::unordered_set (smaller and faster)
- Remove cache entries after having been validated inside a block, to keep the cache fresh.
Concept ACK Sent from my iPhone
|
concept ACK |
|
||
boost::unique_lock<boost::shared_mutex> lock(cs_sigcache); | ||
|
||
while (static_cast<int64_t>(setValid.size()) > nMaxCacheSize) | ||
while (memusage::DynamicUsage(setValid) > nMaxSize) |
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.
OOI, what is the time complexity of memusage::DynamicUsage
?
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.
O(1).
concept ACK, utACK 👍 |
bool | ||
Get(const uint256 &hash, const std::vector<unsigned char>& vchSig, const CPubKey& pubKey) | ||
Get(const uint256& entry) |
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.
Get
is such a weird name, its really more like Contains
?
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.
I think it's going for a getter/setter paradigm(see: Set function below), but I think the names could indeed be improved. It's confusing to have "Set" be both the type of data structure and the primary way of updating it, imo.
Added a commit that removes cache entries after they've been seen in a block, so the cache remains fresh. |
re-ACK |
class CSignatureCacheHasher | ||
{ | ||
public: | ||
size_t operator()(const uint256& key) const { |
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.
Just a qustion to understand the motivation, why is here the opening bracket in the same line and below (line 48) it's on a new line?
Added a commit to not wipe the cache from TBV. |
Currently gathering statistics about the cache size - hitrate relation. |
utACK |
Concept ACK. However in my first attempt at benchmarking I'm not seeing any speedup with this code change (in fact block verification times seem to have gotten very, very slightly slower for some reason). Will continue to debug and try to see if my benchmarking is broken, or if there's some effect here we're missing. |
Sorry forgot to update with my results. I ran longer studies comparing the old and new behavior more carefully and yes I agree this does improve things. I saw roughly a 5% speed up in processing all the October historical data using the new default cache size compared with the old implementation (running with a sig cache of approximately the same size). ACK |
ACK |
Bitcoin 0.12 performance improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6918 - bitcoin/bitcoin#6932 Part of #2074.
Bitcoin 0.12 performance improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6918 - bitcoin/bitcoin#6932 Part of #2074.
Bitcoin 0.12 performance improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6918 - bitcoin/bitcoin#6932 Part of #2074.
Bitcoin 0.12 performance improvements Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6918 - bitcoin/bitcoin#6932 Part of #2074.
6706c20 Don't wipe the sigcache in TestBlockValidity (furszy) c69e354 Evict sigcache entries that are seen in a block (Pieter Wuille) fb3a4a6 Make sigcache faster and more efficient (Pieter Wuille) Pull request description: Coming from bitcoin#6918 . > Changes the -maxsigcachesize argument from entries to megabytes > Change the default to 40 MiB (as opposed to ~10 MiB before), corresponding to over 500000 entries on 64-bit systems. > Store salted SHA256 hashes in the cache, rather than full entries. > Switch implementation from std::set to boost::unordered_set (smaller and faster) > Remove cache entries after having been validated inside a block, to keep the cache fresh. ----- This is the first step towards an up-to-date sigcache. Next one will be to back port the CuckooCache implementation. ACKs for top commit: random-zebra: ACK 6706c20 Fuzzbawls: utACK 6706c20 Tree-SHA512: 3b96c6a9bbbfc5c335644bf66a3605575f66ace88046411386c6a28eee37a6537bac7e25e3eebc4a2b07a82b918385ac82b68349655ab3d7e32a018ef240a908