perf: add optimization for push and pop#3263
Merged
rakita merged 6 commits intobluealloy:mainfrom Jan 5, 2026
Merged
Conversation
CodSpeed Performance ReportMerging #3263 will degrade performance by 3.46%Comparing Summary
Benchmarks breakdown
|
rakita
reviewed
Dec 30, 2025
rakita
reviewed
Dec 30, 2025
rakita
reviewed
Dec 30, 2025
| let end = self.data.as_mut_ptr().add(len); | ||
| core::ptr::write(end, value); | ||
| self.data.set_len(len + 1); | ||
| } |
Member
There was a problem hiding this comment.
This is nice! we didn't optimize this function as it is not used that much, PUSH opcodes use optimized push_slice
rakita
reviewed
Dec 30, 2025
| #[cfg_attr(debug_assertions, track_caller)] | ||
| pub fn push(&mut self, value: U256) -> bool { | ||
| // In debug builds, verify we have sufficient capacity provisioned. | ||
| debug_assert!(self.data.capacity() >= STACK_LIMIT); |
Member
There was a problem hiding this comment.
It looks there was a bug here
Suggested change
| debug_assert!(self.data.capacity() >= STACK_LIMIT); | |
| debug_assert!(self.data.capacity() > STACK_LIMIT); |
Capacity equal to STACK_LIMIT is checked in the line below.
Contributor
Author
There was a problem hiding this comment.
Mistake, it's meant to be assume
Member
There was a problem hiding this comment.
Will revert this line, it was correct previously. assume would not do anything here as we are handling pointers.
rakita
reviewed
Jan 5, 2026
rakita
approved these changes
Jan 5, 2026
Merged
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.
make push 5.4x faster
Pop not much changes but we can add likely and unlikely instrincts
https://godbolt.org/z/8a5GKj4WT