docs(hr-benchmarking): guide JavaScript performance hunts

Merged
BO
11h ago
+36-0

The JavaScript benchmarking reference explains how to measure a suspected bottleneck but gives little help choosing what to investigate or deciding whether synchronous work should become asynchronous.

Add a hunt checklist based on work counts, growth with input size, queueing, and resource lifetimes. Explain how to compare async I/O, chunked yielding, and reused workers using responsiveness, CPU, memory, and transfer costs. Include runtime checks for Cloudflare Workers, Bun, Electron, web, and React Native, with official Node and Cloudflare documentation links.

This stays in the existing benchmarking reference and adds no skill, dependency, or always-on rule. Apply the checklist during a performance investigation; it does not call for changing cold code or moving every synchronous call to a worker. The observed failure was treating component timings as whole-server evidence and carrying guessed worker thresholds into guidance. The new wording requires representative concurrency and distinguishes loop stalls from total work. Its effect on future agent behavior has not been evaluated.

Validation: Node tests (151 passed, 7 skipped); Bun tests (488 passed, 8 skipped); skill tests (338 passed); package verification with Bun; lint; formatting; and guidance-link checks all passed. Lint reports one warning in an unchanged test file. The added prose passes the writing check; the existing reference retains eight pre-existing writing cues.

  • The checks in the README's Development section pass.
  • A change users will notice has a CHANGELOG.md entry under Unreleased.
  • Nothing names a private project or repository, a local path, a home directory or a credential.

Summary by CodeRabbit

  • Documentation
    • Added guidance for selecting JavaScript/TypeScript performance investigations, using representative workloads, counting work, and varying one input at a time.
    • Expanded advice on assessing repeated work, resource lifetimes, synchronous blocking, and long stalls.
    • Added comparison guidance for reducing work, async I/O, yielding, and reused workers, including equal-work, concurrency, responsiveness, and resource measurements.
    • Included runtime-specific measurement caveats and criteria for recording results and stopping investigations.