Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
Already on GitHub? Sign in to your account
[Qt] Reduce a significant cs_main lock freeze #10231
Conversation
jonasschnelli
added
GUI
Needs backport
labels
Apr 19, 2017
|
Can the GUI instead cache the current best tip? This may help with @ryanofsky's process split as well. |
|
@TheBlueMatt: Yes. @theuni recommended this on IRC and I'm currently changing it. |
|
Moved the cache from the core validation logic to the GUI. |
| - if (!pindexBestHeader) | ||
| - return 0; | ||
| - return pindexBestHeader->nHeight; | ||
| + if (cachedBestHeaderHeight == 0) { |
gmaxwell
Apr 19, 2017
Member
Where is this initialized? -- these don't have static duration AFAICT.
Also is zero really the best value to use? -- it's in range, so it'll keep relocking again while there is no data there.
|
What does the GUI use the header time/height for as opposed to the tip? |
jonasschnelli
added some commits
Apr 19, 2017
|
Thanks @gmaxwell. Added the missing initialisation and switched to
The only use case is to calculate the remaining blocks to download/validate (modal sync progress overlay). |
| @@ -72,20 +74,28 @@ int ClientModel::getNumBlocks() const | ||
| return chainActive.Height(); | ||
| } | ||
| -int ClientModel::getHeaderTipHeight() const | ||
| +int ClientModel::getHeaderTipHeight() |
| + // otherwise we need to wait for a tip update | ||
| + LOCK(cs_main); | ||
| + if (pindexBestHeader) { | ||
| + cachedBestHeaderHeight = pindexBestHeader->nHeight; |
|
utACK |
jonasschnelli
added some commits
Apr 20, 2017
|
Followed @luke-jr's advice and re-set the method to @gmaxwell, @TheBlueMatt: thanks for a re-ack. :) |
|
Less blocking of the gui on cs_main is always a good thing, thanks! |
jonasschnelli commentedApr 19, 2017
•
Edited 1 time
-
jonasschnelli
Apr 20, 2017
I can't remember why we added this in the first place: but in current master, we request a
cs_mainlock (not a try lock) every block tip update in order to get the best headers height / time.This results in significant freezes in the GUI during IBD/catch-up.
This PR adds two atomic caches for the best headers height and time.
If we do a 0.14.1rc3, we should consider adding this.