Skip to content

Resolve manifest refs lazily to avoid OOM on large shards#26

Merged
Shane98c merged 1 commit into
mainfrom
fix/lazy-manifest-refs
Jun 24, 2026
Merged

Resolve manifest refs lazily to avoid OOM on large shards#26
Shane98c merged 1 commit into
mainfrom
fix/lazy-manifest-refs

Conversation

@Shane98c

Copy link
Copy Markdown
Collaborator

Reading one chunk materialized the array's whole manifest shard: parseManifest built a ChunkRef object per ref, even though a lookup only needs the one found by binary search. On fine-level virtual manifests (tens of millions of refs) this inflated the heap ~70× and OOM-crashed browser tabs and Node.

Refs now stay in the FlatBuffer and resolve lazily: findChunkRef probes only each ref's coordinates and materializes the single match. For 1M synthetic refs, heap retained after a lookup drops from 345 MB to ~0.

Note: the whole shard is still downloaded and decompressed; the cached manifest retains that buffer, so maxManifestCacheSize bounds count, not bytes (now documented).

Closes #24

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the FlatBuffer manifest parser to resolve chunk references lazily instead of materializing JavaScript objects for all references upfront. This change prevents out-of-memory (OOM) errors when handling large virtual shards. The ArrayManifest interface has been updated to support lazy resolution, and the binary search lookup has been adapted accordingly. Additionally, documentation was added to clarify the memory implications of the manifest cache size, and the test suite was updated to support the new lazy interface. There are no review comments, so I have no feedback to provide.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

@Shane98c Shane98c merged commit ee48e33 into main Jun 24, 2026
12 checks passed
@Shane98c Shane98c deleted the fix/lazy-manifest-refs branch June 24, 2026 20:21
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.

Reading one chunk loads the entire manifest shard into JS (~70× blowup) — OOMs on large virtual stores

1 participant