Skip to content

Memoize EIP-4881/EIP-3076 spectest fixture - #17367

Open
syjn99 wants to merge 3 commits into
developfrom
test/memoize-spec-fixture
Open

Memoize EIP-4881/EIP-3076 spectest fixture#17367
syjn99 wants to merge 3 commits into
developfrom
test/memoize-spec-fixture

Conversation

@syjn99

@syjn99 syjn99 commented Aug 18, 2026

Copy link
Copy Markdown
Member

What type of PR is this?

Other

What does this PR do? Why is it needed?

We're currently removing Bazel which means we will soon rely on go test for our testing harness. One of the bottleneck that we have for running go test is running spectest fixtures like EIP-4881 and EIP-3076. ListRunfiles walks 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:

Bonus, this will make #15329 as a low-hanging fruit. See the last commit of branch remove-preelectra-deposit-processing. Also this means we should deliberately omit a new deposit for pre-Electra in E2E tests.

Acknowledgements

  • I have read CONTRIBUTING.md.
  • I have included a uniquely named changelog fragment file.
  • I have added a description with sufficient context for reviewers to understand this PR.
  • I have tested that my changes work as expected and I added a testing plan to the PR description (if applicable).

syjn99 added 3 commits August 18, 2026 08:58
`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.
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.

1 participant