async updateBase#4174
Conversation
… every 16 ancestors during the cleanup loop — so a full 256-block batch gets ~17 yield points instead of 0. - Reordered so c.base / c.baseTxFrame pointer updates happen before the cleanup burst, with oldFrontier = base.parent captured first. If a shutdown cancels us mid-cleanup, ForkedChain invariants stay coherent. - Split wall-clock into persistMs + cleanupMs aggregated over the batch and surfaced in the existing "Finalized blocks persisted" log — the cheapest possible instrumentation to tell you at a glance whether future stalls are disk or cleanup. - processUpdateBase now awaits the async updateBase.
|
@advaita-saha I find all the comments in the PR to be overly verbose. I would suggest removing most of them, just keeping the most necessary. |
| inc sinceYield | ||
| if sinceYield >= cleanupYieldChunk: | ||
| sinceYield = 0 | ||
| await sleepAsync(0.milliseconds) |
There was a problem hiding this comment.
This could be implemented in a simpler way. Why not just add an i index to the iterator and then if i mod 16 == 0 then run the sleep.
There was a problem hiding this comment.
Or maybe the removeBlockFromCache function could become async so you can simply avoid the sleep altogether.
Yes the comments are there mostly for me so intentionally verbose, as I am working on multiple branches with different things. |
| let | ||
| finishTime = Moment.now() | ||
| runTime = (finishTime - startTime).milliseconds | ||
| let runTime = (finishTime - startTime).milliseconds |
There was a problem hiding this comment.
I would remove cleanupMs since that part is no longer blocking the event loop after this change.
Then runTime used here should just equal persistMs
updateBase is now async, yielding once after db.persist() and once every 16 ancestors during the cleanup loop — so a full 256-block batch gets
~17 yield points instead of 0.