Skip to content

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

Description

@lan17

Priority

P2 — Medium — important hardening or API work after the safety foundations.

Problem

Each invocation rebuilds and sorts key material, allocates fallback/label objects, and calls clocks even when metrics are disabled. The safe metrics wrapper also creates callback closures per metric event.

Evidence:

Directional Node 22 results were about 0.74–0.85M simple local hits/s with metrics disabled, 0.466–0.474M/s with default Prometheus metrics, and 0.150–0.154M/s with 20 key arguments.

Acceptance criteria

  • Commit 0-, 1-, and 20-argument local-hit benchmarks.
  • Profile CPU and allocations before implementation changes.
  • Avoid clocks and metric-label work when metrics are disabled.
  • Precompute immutable definition metadata/static labels where possible.
  • Reduce repeated label objects and safe-wrapper closures.
  • Preserve exact counter semantics unless sampling is separately approved.
  • Establish and document a regression budget.

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