-
Notifications
You must be signed in to change notification settings - Fork 36.5k
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
rpc: make gettxoutsettinfo
run lock-free
#6290
Conversation
For leveldb "An iterator operates on a snapshot of the database taken when the iterator is created". This means that it is unnecessary to lock out other threads while computing statistics, and neither to hold cs_main for the whole time. Let the thread run free.
Untested ACK |
ut ACK |
This would mean that But i agree that we should do more of these LOCK space reducing. |
Whoa. Good catch. I expected that this would invoke CCoinsViewDB::GetBestBlock() which accesses just the db and not any internal fields or global state. But it's a virtual. It shouldn't actually be using the cached value at all but query the db. |
Correction: CCoinsViewCache does not derive from CCoinsViewDB (or the other way around), it just wraps one. So there is no problem AFAIK. |
Right. Was following the wrong path... it calls |
57092ed rpc: make `gettxoutsettinfo` run lock-free (Wladimir J. van der Laan)
{ | ||
LOCK(cs_main); | ||
stats.nHeight = mapBlockIndex.find(stats.hashBlock)->second->nHeight; | ||
} |
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.
Couldn't nHeight change before we get to this block, after we start getting the other stats?
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.
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.
Ah, right.
Bitcoin 0.12 RPC PRs 1 Cherry-picked from the following upstream PRs: - bitcoin/bitcoin#6266 - bitcoin/bitcoin#6257 - bitcoin/bitcoin#6271 - bitcoin/bitcoin#6158 - bitcoin/bitcoin#6307 - bitcoin/bitcoin#6290 - bitcoin/bitcoin#6262 - bitcoin/bitcoin#6088 - bitcoin/bitcoin#6339 - bitcoin/bitcoin#6299 (partial, remainder in #2099) - bitcoin/bitcoin#6350 - bitcoin/bitcoin#6247 - bitcoin/bitcoin#6362 - bitcoin/bitcoin#5486 - bitcoin/bitcoin#6417 - bitcoin/bitcoin#6398 (partial, remainder was included in #1950) - bitcoin/bitcoin#6444 - bitcoin/bitcoin#6456 (partial, remainder was included in #2082) - bitcoin/bitcoin#6380 - bitcoin/bitcoin#6970 Part of #2074.
82f9088 Refactor: Remove using namespace <xxx> from /dbwrapper_tests (random-zebra) 6db0b37 rpc: make `gettxoutsettinfo` run lock-free (random-zebra) f009cf4 Do not shadow members in dbwrapper (random-zebra) b7e540c dbwrapper: Move `HandleError` to `dbwrapper_private` (random-zebra) 43004d0 leveldbwrapper file rename to dbwrapper.* (random-zebra) c882dd9 leveldbwrapper symbol rename: Remove "Level" from class, etc. names (random-zebra) f6496da leveldbwrapper: Remove unused .Prev(), .SeekToLast() methods (random-zebra) cacf3c2 Fix chainstate serialized_size computation (random-zebra) a2a3d33 Add tests for CLevelDBBatch, CLevelDBIterator (random-zebra) 94150ac Encapsulate CLevelDB iterators cleanly (random-zebra) 21df7cc [DB] Refactor leveldbwrapper (random-zebra) 2251db3 change hardcoded character constants to a set of descriptive named co… (random-zebra) Pull request description: This backports a series of updates and cleanups to the LevelDB wrapper from: - bitcoin#5707 - bitcoin#6650 [`*`] - bitcoin#6777 [`*`] - bitcoin#6865 - bitcoin#6873 - bitcoin#7927 [`*`] - bitcoin#8467 - bitcoin#6290 - bitcoin#9281 PIVX-specific edits were required to keep the sporks and zerocoin databases in line. [`*`] NOTE: excluding the obfuscation of databases by xoring data, as we might not want this feature (e.g. as zcash/zcash#2598). Otherwise it can be discussed, and added, with a separate PR. ACKs for top commit: furszy: Re ACK 82f9088 . Fuzzbawls: ACK 82f9088 Tree-SHA512: 1e4a75621d2ec2eb68e01523d15321d1d2176b81aac0525617852899ab38c9b4980daecb9056d054e7961fc758a22143edf914c40d1819144a394f2869a8ad57
For leveldb "An iterator operates on a snapshot of the database taken when the iterator is created". This means that it is unnecessary to lock out other threads while computing statistics, and neither to hold cs_main for the whole time. Let the thread run free.
I've been using this patch for about 8 months without issues, including on a node that automatically dumps the information for every N blocks.