Answer a data file request without rescanning the manifest
Maintainers usually reply within 1 day
Nobody has claimed this yet.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 35/100
- Issue type
- Feature
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- typescript
- Domain
- backend, performance
Research direction
Start with backend/src/routes/data.ts:257, services/manifest-source.ts, and services/manifest-queries.ts to trace how a file request scans the manifest and enforces visibility, version, and missing-object rules. The issue proposes a per-version path index but leaves its storage and build strategy for a plan to decide, so first compare those options while preserving the existing route behavior. Done means meeting the stated median and P90 CPU targets at comparable traffic and passing the existing data route tests unchanged.
Written by the indexing model from the issue text.
Description
Part of #2633.
A file request on data.nemar.org (/<id>/<version>/<path>, answered with a 302 to S3) costs 23 to 28 ms CPU at the median, 164 ms at P90, 578 ms at P99, with 62 MB median memory (nemar-api Metrics, last 24 h, 2026-12-02; 995k invocations, 1 "Exceeded CPU Time Limits", 1 "Exceeded Memory"). Workers CPU was $156.76 of the $274.44 November bill (7.87B CPU ms over about 76M requests).
Cause (from the code): each file request streams the version manifest through the scanner (queryManifest in backend/src/routes/data.ts:257, services/manifest-source.ts, services/manifest-queries.ts) to answer one path. The per-isolate memo is keyed by the query, so a client walking every file of a dataset, and a download manager splitting each file into Range requests (seen: range: bytes=158603733-), rescans the manifest for every request: O(files) work per file. #1502 moved to streaming to bound memory, which is right; what is missing is an index that answers one path without a scan.
Proposed direction (for the plan to decide): a per-version path index built once (at publish, or lazily on first scan) and stored where a lookup is cheap (edge cache, KV, R2 or D1 shards keyed by path hash), so the 302 becomes a lookup plus a presign. Range requests for the same path should reuse the resolution. Keep every integrity rule the manifest path enforces today (visibility gate, version resolution, missing-object handling, git-tracked files).
Acceptance: median CPU for a data-file 302 under 5 ms and P90 under 20 ms at comparable traffic, measured on nemar-api Metrics; no change in responses (existing data route tests pass unchanged).
- Dominant language
- TypeScript
- Stars
- 0
- Forks
- 1
- Avg merge
- 4h 48m
- Merged PRs (30d)
- 468
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from nemarOrg/nemar-cli
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
Maintainers usually reply within 1 day
-
testing
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 1 day
All issues in nemarOrg/nemar-cli
Similar issues
-
Codex使用可 かんたん コード
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
ryuki-moro/Nicomaru#348 ·
Maintainers usually reply within 1 day
-
Bug
Difficulty 1/5 Under an hour Newbie friendliness 84/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
area-integrations
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 1 day