-
Notifications
You must be signed in to change notification settings - Fork 16
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
Increase the smallvec
length for Bitfield
#35
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #35 +/- ##
=======================================
Coverage 61.16% 61.16%
=======================================
Files 9 9
Lines 497 497
=======================================
Hits 304 304
Misses 193 193 ☔ View full report in Codecov by Sentry. |
This one is ready for review |
On it! |
Thoughts on going even higher to e.g. 128 bytes? This would allow us to support Holesky without heap allocations (1.76M validators ~= 107 bytes minimum). |
Yeah, I think that's a good idea indeed. Bumped to 128 bytes. That gives us ~2M validators which is a reasonable target IMO. |
Oh, looks like I need to do this on |
Replaced by sigp/ethereum_ssz#38 |
Increases the size of the
Bitfield
on the stack to 80 bytes. If thesmallvec
exceeds this then it will allocate to the heap.This has the effect of ensuring that the
Attestation
bitfield can live on the stack for all networks with up to ~1.31M validators.Allocating the
Attestation
to the heap is slow and increase memory fragmentation. This affects attestation deserialisation (happens very frequently) and block deserialisation (happens less frequently, but is latency critical).Why 80 bytes?
Let's look at byte sizes that are a multiple of 8 (64 bits, 1 word). We will assume that the number of validators supported by a given bitfield size is
N * 32 slots * 64 committees * 8 bits
.At the time of writing, Ethereum has 1,071,080 active validators. 80 bytes seems to be a small enough number that gives us some headroom.