Skip to content

perf: use the memory reserved for stack instead of allocating boxes #39

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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

joonazan
Copy link
Contributor

@joonazan joonazan commented Jun 6, 2025

No description provided.

Copy link
Contributor

@antoniolocascio antoniolocascio left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

github-actions bot commented Jun 8, 2025

Benchmark report

Benchmark Symbol Base Eff Head Eff (%) Base Raw Head Raw (%) Base Blake Head Blake (%) Base Bigint Head Bigint (%)
block run_prepared 228,452,352 228,290,736 (-0.07%) 201,173,308 201,011,692 (-0.08%) 159,100 159,100 (+0.00%) 6,183,361 6,183,361 (+0.00%)
precompiles bn254_ecadd 55,852 55,852 (+0.00%) 50,400 50,400 (+0.00%) 0 0 (+0.00%) 1,363 1,363 (+0.00%)
precompiles bn254_ecmul 1,040,671 1,040,671 (+0.00%) 717,727 717,727 (+0.00%) 0 0 (+0.00%) 80,736 80,736 (+0.00%)
precompiles bn254_pairing 83,642,672 83,642,672 (+0.00%) 69,108,188 69,108,188 (+0.00%) 0 0 (+0.00%) 3,633,621 3,633,621 (+0.00%)
precompiles ecrecover 496,651 497,600 (+0.19%) 324,955 325,824 (+0.27%) 0 0 (+0.00%) 42,924 42,944 (+0.05%)
precompiles id 1,282 1,282 (+0.00%) 1,282 1,282 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles modexp 29,127,513 29,127,513 (+0.00%) 29,127,513 29,127,513 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles prepare_for_call 5,746 5,746 (+0.00%) 5,746 5,746 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles process_transaction 84,722,874 84,729,295 (+0.01%) 70,018,982 70,022,715 (+0.01%) 20 20 (+0.00%) 3,675,893 3,676,565 (+0.02%)
precompiles ripemd 8,399 8,399 (+0.00%) 8,399 8,399 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles run_prepared 85,290,370 85,296,787 (+0.01%) 70,509,038 70,512,767 (+0.01%) 4,860 4,860 (+0.00%) 3,675,893 3,676,565 (+0.02%)
precompiles sha256 13,495 13,495 (+0.00%) 13,495 13,495 (+0.00%) 0 0 (+0.00%) 0 0 (+0.00%)
precompiles verify_and_apply_batch 223,747 223,589 (-0.07%) 189,987 189,829 (-0.08%) 2,110 2,110 (+0.00%) 0 0 (+0.00%)

@joonazan
Copy link
Contributor Author

Actually, this probably leaks memory because the code repeatedly MaybeUninit::writes the same memory without dropping it in between.

I'm not sure what is a better design. Maybe the EEs should be in boxes, just boxes allocated in this special way.

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.

2 participants