Skip to content
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

Speed up account ledger a little #2279

Merged
merged 2 commits into from
Jun 2, 2024
Merged

Speed up account ledger a little #2279

merged 2 commits into from
Jun 2, 2024

Conversation

arnetheduck
Copy link
Member

persist is a hotspot when processing blocks because it is run at least once per transaction and loops over the entire account cache every time.

Here, we introduce an extra dirty map that keeps track of all accounts that need checking during persist which fixes the immediate inefficiency, though probably this could benefit from a more thorough review - we also get rid of the unused clearCache flag - we start with a fresh cache on every fresh vmState.

  • avoid unnecessary code hash comparisons
  • avoid unnecessary copies when iterating
  • use EMPTY_CODE_HASH throughout for code hash comparison

`persist` is a hotspot when processing blocks because it is run at least
once per transaction and loops over the entire account cache every time.

Here, we introduce an extra `dirty` map that keeps track of all accounts
that need checking during `persist` which fixes the immediate
inefficiency, though probably this could benefit from a more thorough
review - we also get rid of the unused clearCache flag - we start with
a fresh cache on every fresh vmState.

* avoid unnecessary code hash comparisons
* avoid unnecessary copies when iterating
* use EMPTY_CODE_HASH throughout for code hash comparison
@jangko
Copy link
Contributor

jangko commented Jun 2, 2024

Improvement on my machine:

  • Windows:
    • test_generalstate_json from 2m15s become 1m56s
  • WSL Linux:
    • test_generalstate_json from 2m10s become 2m6s

A real linux machine should be faster. But this already set a new record. It never went below 2 minutes before on my machine.

@arnetheduck
Copy link
Member Author

test_generalstate_json from 2m15s become 1m56s

interesting - I would not have expected it to matter on the general state tests since they're mostly small ..

@arnetheduck arnetheduck merged commit 7f76586 into master Jun 2, 2024
18 checks passed
@arnetheduck arnetheduck deleted the codehash branch June 2, 2024 19:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants