Skip to content

rpc: zero-alloc memory word encoding in JsonStreamLogger#20754

Merged
lupin012 merged 2 commits intomainfrom
lupin012/fix_debug_traceBlockByNumber_with_memory_dump_in_streaming
Apr 24, 2026
Merged

rpc: zero-alloc memory word encoding in JsonStreamLogger#20754
lupin012 merged 2 commits intomainfrom
lupin012/fix_debug_traceBlockByNumber_with_memory_dump_in_streaming

Conversation

@lupin012
Copy link
Copy Markdown
Contributor

@lupin012 lupin012 commented Apr 23, 2026

close #20738

This PR addresses issue #20738 by optimizing how memory words are processed during tracing.

Optimization: Replaced formatMemoryWord (which creates a new string on the heap for every word) with writeMemoryWordRaw.

Mechanism: Hex data with the 0x prefix is now written directly to the JSON stream.

Impact: Significant reduction in GC pressure and elimination of per-word heap allocations, which should prevent OOM crashes during large block traces.

With debug_traceBlockByNumber on block 0x17AEF7D:
main releases: All memory(128G+32G) is used then OS kill it for OOM
branch release: Memory used stable 10G

Replace formatMemoryWord (heap-allocating string) with writeMemoryWordRaw
that writes 0x-prefixed hex directly to the JSON stream, eliminating
per-word allocations in debug_traceBlockByNumber with enableMemory=true.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@lupin012 lupin012 marked this pull request as ready for review April 24, 2026 08:13
@lupin012 lupin012 enabled auto-merge April 24, 2026 08:13
@lupin012 lupin012 added this pull request to the merge queue Apr 24, 2026
Merged via the queue into main with commit 32d71ee Apr 24, 2026
40 of 61 checks passed
@lupin012 lupin012 deleted the lupin012/fix_debug_traceBlockByNumber_with_memory_dump_in_streaming branch April 24, 2026 09:52
lupin012 added a commit that referenced this pull request Apr 24, 2026
… (cherry-pick) (#20787)

This PR addresses issue #20738 by optimizing how memory words are
processed during tracing.

Optimization: Replaced formatMemoryWord (which creates a new string on
the heap for every word) with writeMemoryWordRaw.

Mechanism: Hex data with the 0x prefix is now written directly to the
JSON stream.

Impact: Significant reduction in GC pressure and elimination of per-word
heap allocations, which should prevent OOM crashes during large block
traces.

With debug_traceBlockByNumber on block 0x17AEF7D: main releases: All
memory(128G+32G) is used then OS kill it for OOM branch release: Memory
used stable 10G

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
lupin012 added a commit that referenced this pull request Apr 24, 2026
close #20738

This PR addresses issue #20738 by optimizing how memory words are
processed during tracing.

Optimization: Replaced formatMemoryWord (which creates a new string on
the heap for every word) with writeMemoryWordRaw.

Mechanism: Hex data with the 0x prefix is now written directly to the
JSON stream.

Impact: Significant reduction in GC pressure and elimination of per-word
heap allocations, which should prevent OOM crashes during large block
traces.

With debug_traceBlockByNumber  on block 0x17AEF7D:
main releases: All memory(128G+32G) is used then OS kill it for OOM
branch release: Memory used stable 10G

Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
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.

debug_traceBlockByNumber produces invalid JSON stream for block 24833917

2 participants