fix(ctb): stream layer payloads to disk instead of storing them all in RAM - #10
Open
Jo-Con-El wants to merge 1 commit into
Open
fix(ctb): stream layer payloads to disk instead of storing them all in RAM#10Jo-Con-El wants to merge 1 commit into
Jo-Con-El wants to merge 1 commit into
Conversation
…e job CtbRleStreamingEncoder retained every layer's encoded (RLE+XOR) bytes in a Vec for the entire lamination and only released them at finalize, which OOMs on large 3DAA jobs at high resolution (retained bytes grow linearly with layer count and never plateau). It now writes each layer's payload straight to a scratch file as it arrives (with a small out-of-order reorder buffer, since parallel post-processing can finish layers out of index order) and keeps only a lightweight per-layer record in memory. finalize_to_path streams the non-encrypted CTB v5 container straight to the destination file; encrypted (v5enc) output still assembles in memory at finalize time, since its pointer table needs random access, but no longer accumulates during the job itself. build_ctb_container_bytes_with_progress is refactored to share this streaming payload writer instead of triple-copying the payload region (prepared Vec -> layer_payload_data -> out) on every non-streaming call too.
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.
CtbRleStreamingEncoder kept every layer's encoded bytes in memory for
the whole job, which OOMs on large 3DAA jobs at high resolution. Layers
now stream straight to a scratch file as they arrive (reordered if
needed) and finalize_to_path writes the non-encrypted CTB v5 container
straight to disk. Encrypted (v5enc) output still assembles in memory
at finalize time — its pointer table needs random access — but no
longer accumulates during the job itself.