Repository navigation
Description
Symptom
Dataset detail pages for large BIDS-EEG datasets load slowly or time out on first visit. Examples:
| Dataset | manifest.json served by data.nemar.org | Time to download (typical) |
|---|---|---|
| on005261 | 10.5 MB | 8–15 s |
| nm000103 | 7.9 MB | 6–12 s |
| nm000166 | 4.9 MB | 4–8 s |
| on004362 | 5.2 MB | 4–8 s |
Users report: "First load slow / times out, switching browser made it almost-instant" — that's the CF edge cache making the 10 MB blob warm. First-load is the actual experience for every new visitor.
Root cause
data.nemar.org/<id>/<version>/manifest.json (backend/src/routes/data.ts:200-251) takes the stored manifest (~4-5 MB for these datasets) and adds a freshly-minted presigned S3 URL to every single file entry on every request. The URL is ~400-800 bytes; multiplied by 14,536 files in on005261 → ~10 MB of signature data per response.
The website's two API endpoints (/api/dataset/<id>/readme and /tree) both fetch this full manifest just to extract:
- readme: the URL of one entry whose path matches
^readme(\.md|\.txt)?$ - tree: the path strings (the per-entry presigned URLs are unused)
We're serving 10 MB of presigned URLs to use 50 KB of path data.
Proposal: compact summary.json artifact
Generate a path-only summary at manifest creation time, stored alongside the manifest:
s3://nemar/<id>/version/v<X.Y.Z>-summary.json ~ 50–200 KB even for 15k-file datasets
{
"schema_version": "1.0",
"dataset_id": "on005261",
"version": "1.0.0",
"doi": "10.82901/nemar.on005261.v1.0.0",
"totals": { "files": 14536, "bytes": 241618664825, "subjects": 17 },
"modalities": ["meg", "beh"],
"subjects": ["sub-01", "sub-02", ...],
"readme": { "path": "README.md" } | null,
"paths": ["README.md", "dataset_description.json", "sub-01/...", ...]
}
Critically:
- No presigned URLs — the summary is path-only. URLs are minted on demand by data.nemar.org file-download routes that already exist.
- No checksum/size per-file — totals only, sufficient for the page's needs.
Served at data.nemar.org/<id>/<version>/summary.json. Cache-friendly (no per-request work).
Website-side change (this issue)
- New
getSummary(id, version)helper insrc/lib/data-api.ts. /api/dataset/<id>/readmeendpoint:- Fetch
summary.jsonfirst. - If
summary.readmeis set, fetch the README content fromraw.githubusercontent.com(already an existing fallback) or from a newdata.nemar.org/<id>/<version>/README.mdendpoint that signs on demand. - Stop loading the full manifest just to find one entry.
- Fetch
/api/dataset/<id>/treeendpoint:- Build the tree from
summary.paths(path strings only). - Drop the manifest fetch entirely.
- Build the tree from
- Fallback: if
summary.json404s (older datasets without backfill), fall back to the current manifest-based path. This keeps the change deployable independent of the backfill.
Companion work on nemar-cli
Generating summary.json is a nemar-cli/data-layer concern. Tracked in a separate issue there. Until that lands, this change is a no-op (fallback path runs). Once summary.json is published for new datasets, the page is fast. Once backfilled for the 5 recently-recovered datasets (on005261, nm000103, nm000106, nm000166, on004362), they're fast too.
Acceptance
-
/api/dataset/on005261/tree?v=v1.0.0returns in < 500 ms instead of timing out -
/api/dataset/on005261/readme?v=v1.0.0returns in < 500 ms even on a cold cache - First-load of
/dataset/on005261feels instant (modulo network RTT) regardless of browser cache state - Pre-existing datasets without a backfilled summary still render correctly via the fallback path
Notes
- Related: companion issue on this repo (filed alongside) for the "no published version" 500-then-429 case, which is independent of the summary artifact.
- The summary should be regenerable: backfilling old datasets is just running the manifest-recovery script (
/tmp/manifest_recover.pyused today) with a--also-summaryflag. No new infrastructure needed.
Activity
feat(dataset): consume compact summary.json with manifest fallback
Stream C: summary.json route + 5-dataset backfill (#558)