feat(#5902): flag-gated bounded-memory SegmentedWriter (dark)#5916
Merged
Conversation
… gate (#5902) Bounded-builder segmented graph writer: flush a finished seg-NNNN.fb and start a fresh flatbuffers.Builder whenever the builder crosses GRAFEL_SEGMENT_BYTES (default 100MB), so peak builder memory stays ~one threshold instead of O(graph) (fixes the #5726 2GiB serialize cliff). Entity and relationship segments flush on independent cadences into separate files. Each entity segment is the contiguous sorted id slice with exact byte-wise MinKey/MaxKey bounds, so the reader's key-range routing never false-skips a present entity. Small graphs take the single-file fast path (plain graph.<gen>.fb, byte-identical to today). Flag OFF by default; gated at WriteGraphGen so every producer call site routes through one switch. No fbversion bump; readers unchanged.
…h, flag-off parity, independent streams (#5902)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part (c) of #5890. Streaming SegmentedWriter that produces the segmented format the #5901 reader already routes. FLAG-GATED via
GRAFEL_STREAM_SEGMENTS(OFF by default → byte-identical to today); NO fbversion bump. Closes #5902.GRAFEL_SEGMENT_BYTES(default 100 MB) it flushes tograph.<gen>/seg-NNNN.fb, frees the builder, repeats — peak builder stays ~one threshold, fixing the bug(fbwriter): daemon hard-crashes ('panic: cannot grow buffer beyond 2 gigabytes') marshaling large graphs → severs all MCP bridges #5726 2 GiB serialize cliff (a >2 GiB graph splits instead of panicking). Relationships flush on their own cadence (decision 5).<== FB(key)memcmp == readerKeyRange.contains), streamed globally-sorted, cut at threshold → segments tile the id space contiguous + non-overlapping;MinKey/MaxKey= first/last id per segment. Multi-segment write→read round-trip proves every entity resolves through the routed reader.graph.<gen>.fb, byte-identical to today.Independently reviewed, mutation-proven: routing-bounds-match-reader (descending-sort / shrunk-MaxKey / overlap mutations caught), bounded-builder (retention mutation caught), single-file + flag-off byte-parity, NextGen monotonicity, edge cases (empty/single/rel-only/prefix-ids/dup-straddle). 308 + 3965 + 282 tests pass.
🤖 Generated with Claude Code
https://claude.ai/code/session_017quGgaqK7NRoxGT6BTqV2o