performance: keep trie prefetch during validation phase #1954
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Recently, we saw some nodes spent lots of time on block validation phase, could even longer than 6 seconds, which leads to slash of some validators. We found out it is caused by some giant transactions, like XenCrypto. Take this transaction for example: https://bscscan.com/tx/0x5d948f50b9f1245fc4c9feaff71e02c607468d9540c33606253fa89998e9b7d8, which consumed ~40M gas in a single transaction.
It is quite unfriendly to the current trie prefetch logic, which is terminated right after entering validation phase, since
getTrie()
will stop the trie prefetch.This PR tries to keep trie prefetch until validation phase is completed, which will call
StopPrefetcher()
at the end ofStateIntermediateRoot()
.Test Result:
For these long time validation phase, the validation time could be reduced by more than 80%, which is a huge improve.
Metrics of the test:
Rationale
NA
Example
NA
Changes
NA