Skip to content

Zero copy deserialization to reduce GC pressure#4

Draft
eclairss17 wants to merge 5 commits into
masterfrom
zero-copy-deserialization
Draft

Zero copy deserialization to reduce GC pressure#4
eclairss17 wants to merge 5 commits into
masterfrom
zero-copy-deserialization

Conversation

@eclairss17

Copy link
Copy Markdown
Owner

During block verification DeserializeProof, creates a copy of each stem which creates high volume GC pressure during high throughput scale. We introduce a shared view of reference buffer that stores the deserialized proof in its wire format, along with a counter to track number of ProofViews reading from it without having to copy each stem.

Benchmark Results (Apple M1 Pro, Go 1.23, go test -benchmem -benchtime=5s)

BenchmarkCopying_10K              566,760 B/op   10,001 allocs/op   146 µs/op
BenchmarkZeroCopy_10K             242,004 B/op   10,003 allocs/op   242 µs/op
BenchmarkZeroCopy_AccessOnly           42 B/op        1 alloc/op     3.4 µs/op
BenchmarkZeroCopy_SingleProofView       0 B/op        0 allocs/op   14.2 ns/op

GC Memory Overhead Results

Heap allocation reduction per node:

Copying:    566 KB × 7,200 blocks/day  = ~3.97 GB allocated and freed per day
                                        = ~1.45 TB per year per node
Zero-copy:  242 KB × 7,200 blocks/day  = ~1.70 GB allocated and freed per day
                                        = ~0.62 TB per year per node
Savings:    ~2.27 GB/day per node      = ~829 GB/year per node

Aggregate across the network (6,000 nodes):

Per day:    2.27 GB × 6,000 nodes  = ~13.6 TB of heap churn eliminated per day
Per year:   829 GB × 6,000 nodes   = ~4.85 PB of heap churn eliminated per year

@eclairss17 eclairss17 self-assigned this Mar 31, 2026
@eclairss17 eclairss17 linked an issue Mar 31, 2026 that may be closed by this pull request
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.

Dont copy memory during proof deserialization

1 participant