Skip to content

records.ndjson: stream leaf bodies, and produce lines as the client reads - #41

Open
3mcd wants to merge 1 commit into
mainfrom
records-stream-memory
Open

3mcd wants to merge 1 commit into
mainfrom
records-stream-memory

Conversation

@3mcd

@3mcd 3mcd commented Oct 15, 2026

Copy link
Copy Markdown

Reading crossref-demo/works v5.2.x, records.ndjson died with "Worker exceeded memory limit" wherever the next leaves were large, after sending its 200 and count header, so clients saw an empty stream. Leaves end at a key-hash boundary (mean 1,024 entries, up to 8,192): book-chapter's first leaf in v5.2.1 holds 6,920 records, about 80 MB of bodies, and iterate decoded whole leaves through bodyLines (cached in the LRU), four ahead. The stream also did all its work in start(), enqueueing regardless of how fast the client read.

iterate takes stream: with payloads, each leaf is read through leafStream (gunzipped line by line, not cached), one leaf at a time. records.ndjson uses it and produces up to 512 lines or 1 MB per pull().

…eads

Reading crossref-demo/works v5.2.x, records.ndjson died with "Worker exceeded
memory limit" wherever the next leaves were large, after sending its 200 and
count header, so clients saw an empty stream. Leaves end at a key-hash
boundary (mean 1,024 entries, up to 8,192): book-chapter's first leaf in
v5.2.1 holds 6,920 records, about 80 MB of bodies, and iterate decoded whole
leaves through bodyLines (cached in the LRU), four ahead. The stream also did
all its work in start(), enqueueing regardless of how fast the client read.

iterate takes `stream`: with payloads, each leaf is read through leafStream
(gunzipped line by line, not cached), one leaf at a time. records.ndjson uses
it and produces up to 512 lines or 1 MB per pull().

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant