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

perf(coverage): cache current HitMap, reserve when merging #9469

Merged
merged 3 commits into from
Dec 3, 2024

Conversation

DaniPopes
Copy link
Member

@DaniPopes DaniPopes commented Dec 3, 2024

Avoid one of the two hashmap lookups in CoverageCollector::step() by caching the current contract's hashmap in a separate field. This unfortunately has to use a raw pointer and unsafe because self-referential structs are not possible.

Additionally, add some reserve calls and initialize with some initial capacity to reduce the impact of reserve(1) in entry calls.

10-20% faster forge coverage on solmate.

@DaniPopes DaniPopes force-pushed the dani/coverage-perf-mapstack branch from c779922 to 13be916 Compare December 3, 2024 13:06
@DaniPopes DaniPopes force-pushed the dani/coverage-perf-mapstack branch from d45bce7 to 7aefb03 Compare December 3, 2024 17:01
@DaniPopes DaniPopes marked this pull request as ready for review December 3, 2024 17:14
@DaniPopes DaniPopes changed the title perf(coverage): use a stack of hit maps perf(coverage): cache current HitMap, reserve when merging Dec 3, 2024
@DaniPopes DaniPopes enabled auto-merge (squash) December 3, 2024 18:31
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cool, makes sense,
some doc suggestions

crates/evm/coverage/src/inspector.rs Show resolved Hide resolved
crates/evm/coverage/src/inspector.rs Show resolved Hide resolved
@DaniPopes DaniPopes merged commit 22202a7 into master Dec 3, 2024
21 checks passed
@DaniPopes DaniPopes deleted the dani/coverage-perf-mapstack branch December 3, 2024 20:10
@DaniPopes
Copy link
Member Author

Addressed in #9474

@grandizzy grandizzy added the T-perf Type: performance label Dec 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-perf Type: performance
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants