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
Shows reindex progress in metrics screen #4368
Conversation
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.
Concept ACK. Yes, I would like formatting for the byte sizes; something akin to DisplayDuration()
would be great (except without the FULL
vs REDUCED
format distinction; simply auto-scaling from e.g. kiB -> MiB
with one or two decimal places would be ideal).
src/main.cpp
Outdated
std::atomic<size_t> nSizeReindexed(0); // valid only during reindex | ||
std::atomic<size_t> nFullSizeToReindex(1); // valid only during reindex |
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.
As these are only consumed by the metrics screen, define these in metrics.cpp
alongside the other metrics globals. That also makes it easier to refactor the metrics screen later on to reduce globals.
src/main.h
Outdated
extern std::atomic<size_t> nSizeReindexed; // valid only during reindex | ||
extern std::atomic<size_t> nFullSizeToReindex; // valid only during reindex |
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.
These then move to metrics.h
.
72fc4be
to
8fd575a
Compare
@str4d , thank you for your review. I've addressed your comments and have rebased this PR to current |
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.
Please fix the race condition on fReindex
.
I'm generally skeptical about the style of using atomics; we do use them elsewhere but very sparingly, since they're quite error-prone. Is there an applicable existing lock we can use instead (e.g. |
@daira , thank you for review. I'll try to use other way instead of atomics. |
Actually upstream makes |
I've created backporting PR, but I don't know how to make this PR dependent on it. Just rebase this branch on its branch? |
@gladcow wrote:
Yes. |
8fd575a
to
0579123
Compare
I've rebased this PR on #4387 |
Fix races in AppInitMain and others with lock and atomic bools (Bitcoin backport) Backport bitcoin bitcoin/bitcoin#11107 (excluding the last commit, it was fixed in Zcash before). This functionality is required for #4368 (details #4368 (comment)) as part of the issue #3813 resolution.
Please rebase this on master so that this PR only contains the relevant commits. |
0579123
to
fc2501b
Compare
@str4d , done.) |
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.
utACK
@zkbot r+ |
📌 Commit fc2501b has been approved by |
nFile++; | ||
fullSize += boost::filesystem::file_size(blkFile); | ||
} | ||
nFullSizeToReindex = fullSize; |
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 missed a potential divide-by-zero. If all block files are zero-length, then https://github.com/zcash/zcash/pull/4368/files#diff-9bee7abc3e254b85a1ce1ed330601054R291 can divide by zero.
…sh#4368. Signed-off-by: Daira Hopwood <daira@jacaranda.org>
Avoid a theoretical possibility of division-by-zero introduced in #4368 Signed-off-by: Daira Hopwood <daira@jacaranda.org>
Resolves issue #3813.
The "Downloading blocks" message is changed to "Reindexing blocks" during reindex, after reindex is completed the text is reverted back to the first variant.
Reindex progress is shown as a sum of processed file size (we can't use reindexed block number as a progress because we can't predict how many blocks to process at all, we don't know the size of the block before we process it), the result looks like