fix: bound IVF-RQ serialization allocations - #93
Open
jackylee-ch wants to merge 1 commit into
Open
Conversation
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.
Summary
write_ivfrq_indexmaterialized a full byte copy of each f32 section before writing it. The quantizer centroid section isnlist * dfloats, bounded only byMAX_SECTION_ELEMENTS, so serializing a large index could allocate several GiB transiently on top of the resident centroids. Stream those sections through one reusable 64 MiB write buffer, mirroring #77 for IVF-Flat.Testing
ivfrq_chunked_writer_preserves_format_and_boundsasserts byte-identical output and a bounded maximum write. Without the buffer the centroid section goes out as one 32768-byte write and the test fails.cargo test --release --workspace(503 passed), includingstorage_format_fixturescargo fmt --all -- --check,cargo +1.98.0 clippy --release --all-targets --workspace -- -D warningsNotes
No public API, index option, or file-format change; output is byte-for-byte identical and independent of chunk boundaries. The per-list code and factor buffers built by
block_listare unchanged.