Skip to content

Establish a local-hit performance budget and remove avoidable hot-path work #43

Description

@lan17

Priority

P2 — Medium — benchmark-led optimization after production safety guardrails.

Current state

Each enabled invocation still constructs a key, resolves configuration, allocates its fallback closure, and calls clocks on measured cache/fallback paths. With metrics omitted, optional chaining already skips most metric label construction and adapter calls, so the original claim that every label object is built unconditionally is stale. performance.now() and the synthetic default-provider/async path remain avoidable candidates.

Current evidence:

Scope

Profile first, then remove only measured hot-path work:

  • Skip clocks entirely when metrics are absent.
  • Skip the synthetic config-provider call/await when no custom provider exists and use the definition's static default directly.
  • Precompute immutable definition-level label metadata where measurement supports it.
  • Reduce safe metrics-wrapper closures without changing fail-open behavior or event semantics.
  • Add 0-, 1-, and 20-argument local-hit scenarios through Add a repeatable performance and scale benchmark suite #35.

Out of scope

  • Cache-key identity changes.
  • Counter sampling or metric semantic changes.
  • Built-in memoization/timeouts for caller-supplied dynamic config providers.
  • Vendor-client encoding optimizations inside core.
  • Performance claims without warmup, repeated samples, and captured environment.

Acceptance criteria

  • Reproducible before/after results through the shared harness.
  • CPU/allocation profile identifies each changed cost.
  • Metrics-disabled paths avoid unnecessary clocks.
  • No-custom-provider calls avoid the synthetic async provider path.
  • Metrics-enabled counters/timers and throwing-adapter isolation remain exact.
  • No public API or Redis wire change unless separately approved.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions