Reduce nemar-api's per-request CPU floor

Open
#2,687 0 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
typescript

Research direction

Start by reading the profiling results and candidate work in this issue, then trace the request paths for file redirects and route setup. Measure each candidate change before implementing it, and compare CPU costs against the stated warm request and isolate startup baselines. Done means a measured reduction in the per-request CPU floor with the production impact checked.

Written by the indexing model from the issue text.

Description

Part of #2633. Filed under the owner's decision on #2635's acceptance (2026-12-02): the per-request CPU floor gets its own issue.

Measured on 2026-12-02:

  • Production, nemar-api Workers Observability, data.nemar.org, last 24 h: CPU per request mean 76.87 ms, median 24 ms, P90 212 ms. nm000229's requests (the largest single client) have a median of 6 ms.
  • Local profile of the bundled Worker in workerd (step S2A of the plan): a warm file request costs about 4.2 ms of CPU (scan 1.2 ms), a repeat about 2.1 ms. A fresh isolate costs about 72 ms of module evaluation plus about 25 ms for its first request, half of which is Hono building its route matchers. Four copies of zod are 29% of module evaluation; GC is 24%. loadVersionRows (a D1 query) runs on every file 302 and is not used there.

So the typical request carries about 18 ms above the warm floor, which isolate start-up or per-request work the profile could not reproduce may explain. The path index and per-path cache (ADR 0150) address the tail, not this floor.

Candidate work, to be measured before changing anything: dedupe zod in the bundle; defer route matcher construction; skip loadVersionRows on the file 302 path; add a per-isolate request counter to Server-Timing to measure production isolate churn.

Dominant language
TypeScript
Stars
0
Forks
1
Avg merge
4h 48m
Merged PRs (30d)
468

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from nemarOrg/nemar-cli

All issues in nemarOrg/nemar-cli

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.