Repository navigation
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35071. ReviewsSee the guideline for information on the review process. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Not sure about slowing down the happy path for an edge case: Reindex is already rare (hopefully?), and power outage during reindex should be doubly-rare. Also, writing the out-of-order blocks seems duplicate effort. Shouldn't it be trivial and fast to read them from the existing block files instead of going the extra hop through the leveldb? I guess it could make sense to have a flame graph showing the actual overhead that is seen when continuing a reindex. Without actual data it is hard to optimize it. If I had to guess, is the overhead from Alternatively, the overhead is so minimal, that it doesn't matter? |
|
I could've used this at least in the
Yeah saving the map after every file is a bummer, but we only need to read the map if we restart after an interruption, so there shouldn't be any hopping.
I could use a bit of clarity on what you're referring to as overhead here ? |
Well, I couldn't find a large overhead myself (but I only tried signet so far), so maybe I am missing something. Let's recall that So I guess it could make sense to see a flame graph or anything else to see where the bottleneck is on your side. I see you have measured a reindex with this branch and saw that it is slower. But have you measured a resume and seen that it is faster? If yes, why is it faster? Knowing this will make it easier to find alternative solutions. I can also imagine that the performance depends on the storage device that hosts the blocks dir. If that is on a network drive, then |
mzumsande
left a comment
There was a problem hiding this comment.
Not sure about slowing down the happy path for an edge case: Reindex is already rare (hopefully?), and power outage during reindex should be doubly-rare.
I think agree with that. I think there is a use case for handling user interrupts, or for flushing after the first phase when all block files are indexed, but accommodating unclean restarts during reindex seems too much of a special case.
595c5d0 to
14b586d
Compare
|
push to 14b586d1c3:
|
…start Adds two new keys to the BlockTreeDB that are written only if reindex is interrupted: - The last file read - A serialized map of orphan blocks If a reindex is interrupted, these values are read on restart and the reindex progress continues from the checkpoint. This does not affect runs with the -reindex flag explicitly set, which always wipes the index and starts from blk00000.dat
14b586d to
99d0d61
Compare
|
Push to 99d0d61:
|
|
I still don't understand what this is trying to do. If this is a performance improvement, you should say so, and also provide the reason for the improvement (possibly with flamegraphs or so), and benchmarks. |
|
It is not a performance improvement. It addresses grief from restarting a lengthy reindex process if it was interrupted by the user. Motivated by my own experience. The only reason performance was mentioned is because my original solution reduced performance. The current version of the branch does not because now we only write reindex state once, on interruption, as opposed to 5,000 times during the process. |
|
Sorry, I meant how much of a performance improvement is this under the scenario of an interrupt. Because personally I didn't see any overhead on restarts, see #35071 (comment). Without seeing that this improves anything for anyone (with performance numbers or graphs), then I don't see the point. |
|
Master: Branch: If you want me to look in to why a reindex takes 3.5 hours, I'm happy to do that. It's just not the UX I'm going for here. |
|
As long as you drop the |
|
Huh, I thought the bulk of the changes should be in Edit: Ok, so you didn't disable the In that case, my suggested solution would be to always stop the node immediately when |
Oh crap I didn't realize this. I just saw
No I did, but I was misunderstanding our dialog. I'll switch to draft for now and get actual measurements on re-re-index to see if this branch actually improves anything. |
|
I actually think this branch doesn't change anything, if the -reindex is supplied twice and started again from scratch. At least, I would object if dirty state is persisted in the db between reindex runs. |
Agreed, yeah here's the question: Does user experience time of run 1 + run 2 = run 3 ? run 1: run 3: |
Currently, if the reindex process is interrupted it will start over on next run at
blk00000.dat. Even after reindexing is finished when the node is inActivateBestChain()an interruption may STILL require a full reindex process becauseDB_REINDEX_FLAGis writtenfalse, but not flushed.Mentioned in #30424 but I couldn't find any specific follow-up:
The solution in this PR is simply to write a new field
DB_REINDEX_LASTFILEwhen reindex is interrupted and flush theDB_REINDEX_FLAGsetting when the process is complete. The complication is that blocks may be out of order on disk and so as we reindex we store orphan blocks temporarily in memory until they are reconnected with their parent in later files. To ensure that data is recovered, the orphan map is serialized and also saved to the database asDB_REINDEX_ORPHAN_BLOCKS.