Skip to content

perf: add MarshalAppend APIs and increase buffer capacity#12

Merged
Lunkers merged 3 commits intoEyevinn:mainfrom
CarlLindqvist:perf/marshal-append-and-buffer-capacity
Apr 17, 2026
Merged

perf: add MarshalAppend APIs and increase buffer capacity#12
Lunkers merged 3 commits intoEyevinn:mainfrom
CarlLindqvist:perf/marshal-append-and-buffer-capacity

Conversation

@CarlLindqvist
Copy link
Copy Markdown
Contributor

Summary

  • Add MarshalVmapAppend and MarshalVastAppend functions that accept a caller-provided []byte buffer and return the extended buffer. This enables callers to reuse buffers (e.g. via sync.Pool) for reduced GC pressure in high-throughput scenarios.
  • Increase initial buffer capacity in MarshalVmap (8 KB → 256 KB) and MarshalVast (4 KB → 128 KB) to better match typical document sizes and reduce intermediate growth allocations during marshaling.

Motivation

Profiling the ad-normalizer service showed escText accounting for ~43% of all cumulative allocations (73.8 GB). The allocations were not from the escaping logic itself (which is already efficient) but from repeated []byte buffer growth — starting at 8 KB and doubling through many intermediate sizes for typical 100KB+ VMAP documents.

Test plan

  • All existing tests pass
  • New tests for MarshalVmapAppend, MarshalVastAppend, and prefix preservation
  • Output verified identical to MarshalVmap/MarshalVast

🤖 Generated with Claude Code

CarlLindqvist and others added 3 commits April 15, 2026 14:10
Add MarshalVmapAppend and MarshalVastAppend functions that accept a
caller-provided buffer, enabling buffer reuse via sync.Pool for
reduced GC pressure in high-throughput scenarios.

Also increase initial buffer capacity from 8KB/4KB to 256KB/128KB
to better match typical VMAP/VAST document sizes and reduce
intermediate growth allocations.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Collaborator

@Lunkers Lunkers left a comment

Choose a reason for hiding this comment

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

LGTM

@Lunkers Lunkers merged commit aac7a86 into Eyevinn:main Apr 17, 2026
4 checks passed
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