Skip to content

perf: pool or pre-allocate interned string dict #66

@xe-nvdk

Description

@xe-nvdk

Problem

When string interning is enabled, the encoder/decoder dict (`map[string]int` / `[]string`) is lazily allocated and grows unbounded within a session. Map growth causes internal rehashing allocations. The decoder dict (`[]string`) appends per unique string, causing slice growth allocations.

Proposal

Options:

  1. Pre-allocate dict with a configurable initial capacity
  2. Pool the dict maps/slices via `sync.Pool` and `clear()` on return
  3. Reset and reuse between calls (already partially done in `PutDecoder`)

Files

  • `intern.go` — encoder dict (line ~66), decoder dict (line ~230)
  • `decode.go` — `PutDecoder()` dict cleanup

Expected Impact

LOW-MEDIUM — only affects workloads using string interning. Reduces dict-related allocations and rehashing overhead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    performancePerformance optimization

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions