Skip to content

Pre-allocate in as_ssz_bytes#82

Open
macladson wants to merge 1 commit intosigp:mainfrom
macladson:prealloc-encode
Open

Pre-allocate in as_ssz_bytes#82
macladson wants to merge 1 commit intosigp:mainfrom
macladson:prealloc-encode

Conversation

@macladson
Copy link
Copy Markdown
Member

During encoding, we can pre-allocate the output buffer since we already know the final SSZ length.
This avoids potential re-allocations as the buffer grows during encoding.

From my rough testing, this typically saves around 5-10% with gains up to 50% depending on how much allocation and re-allocation overhead dominates the encoding time

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 22, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.39%. Comparing base (d3ecadb) to head (7bf8e11).

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #82      +/-   ##
==========================================
+ Coverage   82.36%   82.39%   +0.03%     
==========================================
  Files          13       13              
  Lines        1140     1142       +2     
==========================================
+ Hits          939      941       +2     
  Misses        201      201              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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