Skip to content

perf: adaptive encoder pool buffer threshold #62

@xe-nvdk

Description

@xe-nvdk

Problem

PutEncoder() drops the wbuf write buffer if cap > 32KB. If Arc's messages are consistently 50-100KB, every pooled encoder loses its buffer and must re-grow on next use. This causes repeated allocations and GC pressure under sustained load with large messages.

Proposal

Options:

  1. Raise the threshold (e.g., 128KB or 256KB)
  2. Make the threshold configurable via SetPoolBufferLimit(n int)
  3. Use adaptive sizing: track recent max and retain buffers up to 2x the observed max

Also apply the same pattern to the decoder's buf field (currently 32KB threshold).

Files

  • encode.goPutEncoder() (line ~58)
  • decode.goPutDecoder() (line ~45)

Expected Impact

MEDIUM — eliminates buffer re-growth allocations for workloads with consistently large messages. Reduces tail latency spikes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimization

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions