Memoize EIP-4881/EIP-3076 spectest fixture - #17367
Open
syjn99 wants to merge 3 commits into
Open
Conversation
`readTestCases` is called 8 times in the test file, and each time it needs to read 429k files (at `v1.7.0-alpha.11`). Running this test with Bazel is already cheap, but when it comes to `go test`, it takes over 2 minutes to run the package test only because of walking the filesystem and reading the files. ``` go test ./beacon-chain/cache/depositsnapshot/ ``` Now, with this change, the test will read the files only once and cache the result in memory, so the test duration is reduced to 8.6 seconds. All numbers are measured on my local environment (MacBook Pro M5, 48GB RAM).
Same rationale with the previous commit. ``` go test ./validator/client/ -run TestEIP3076SpecTests ``` now takes 14 seconds instead of 24 seconds. Note that the reduced time is not dramatic as the fixture is only called twice in the test package, so basically memoization saves one round of reading and unmarshalling the fixture.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
What type of PR is this?
What does this PR do? Why is it needed?
We're currently removing Bazel which means we will soon rely on
go testfor our testing harness. One of the bottleneck that we have for runninggo testis running spectest fixtures like EIP-4881 and EIP-3076.ListRunfileswalks all the files for spectest (which is over 429k files) so it takes a lot of time as well as memory.This PR reduces over 2 minutes of test duration only by adopting memoization for each spectest fixture. (See each commit description)
Which issue(s) does this PR fix?
N/A
Other notes for review
EIP-4881 code and tests will be merged when
is resolved. And I believe this can be deleted after Kurtosis+E2E migration lands, see the note that I wrote in #15320:
Acknowledgements