Remove AlignedBoxWithSlice wrapper and add alias to Poly<[T], AlignedAllocator>#965
Remove AlignedBoxWithSlice wrapper and add alias to Poly<[T], AlignedAllocator>#965JordanMaples wants to merge 3 commits intomainfrom
Conversation
…907) Introduce AlignedSlice<T> type alias and aligned_slice() constructor in diskann-quantization::alloc, replacing the AlignedBoxWithSlice wrapper struct from diskann-providers. This eliminates an unnecessary abstraction layer and moves aligned allocation to its proper tier. - Add AlignedSlice<T> = Poly<[T], AlignedAllocator> type alias - Add aligned_slice<T>(capacity, alignment) constructor - Migrate all 9 consumer files in diskann-disk - Replace split_into_nonoverlapping_mut_slices with chunks_mut - Replace as_slice/as_mut_slice with Deref/DerefMut - Delete aligned_allocator.rs from diskann-providers - Add 5 tests for aligned_slice Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
This replaces #908 |
There was a problem hiding this comment.
Pull request overview
This PR removes the AlignedBoxWithSlice wrapper from diskann-providers and standardizes aligned slice allocation in diskann-quantization::alloc via a new AlignedSlice<T> alias and aligned_slice() constructor, updating disk-index readers/search code to use the new API.
Changes:
- Add
AlignedSlice<T> = Poly<[T], AlignedAllocator>andaligned_slice<T>(capacity, alignment: PowerOfTwo)indiskann-quantization. - Migrate aligned buffer usage across
diskann-disk(tests/benches/search) to the new constructor and to slice deref semantics. - Remove
diskann-providers::common::AlignedBoxWithSliceand replace custom splitting withchunks_mut.
Reviewed changes
Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| diskann-quantization/src/alloc/mod.rs | Exposes new aligned-slice module + re-exports AlignedSlice/aligned_slice. |
| diskann-quantization/src/alloc/aligned_slice.rs | Introduces AlignedSlice<T> alias, constructor, and unit tests. |
| diskann-providers/src/common/mod.rs | Drops AlignedBoxWithSlice re-export. |
| diskann-providers/src/common/aligned_allocator.rs | Deletes the wrapper implementation (and its tests). |
| diskann-disk/src/utils/aligned_file_reader/windows_aligned_file_reader.rs | Updates tests to allocate aligned buffers via aligned_slice and split via chunks_mut. |
| diskann-disk/src/utils/aligned_file_reader/storage_provider_aligned_file_reader.rs | Same migration as above for storage-provider reader tests. |
| diskann-disk/src/utils/aligned_file_reader/linux_aligned_file_reader.rs | Same migration as above for Linux reader tests. |
| diskann-disk/src/utils/aligned_file_reader/aligned_read.rs | Updates/shortens doc comment reflecting removal of wrapper type. |
| diskann-disk/src/search/provider/disk_vertex_provider_factory.rs | Uses aligned_slice buffer for header reads and relies on deref slicing. |
| diskann-disk/src/search/provider/disk_sector_graph.rs | Switches internal storage to AlignedSlice<u8> and replaces custom splitting with chunks_mut. |
| diskann-disk/src/search/provider/disk_provider.rs | Removes .as_slice() calls; relies on deref to slice for .to_vec(). |
| diskann-disk/src/search/pq/quantizer_preprocess.rs | Replaces .as_mut_slice() with deref-based mutable slicing/borrows. |
| diskann-disk/src/search/pq/pq_scratch.rs | Replaces wrapper fields with AlignedSlice allocations and updates alignment tests. |
| diskann-disk/benches/benchmarks_iai/aligned_file_reader_bench_iai.rs | Updates benchmark to use aligned_slice + chunks_mut. |
| diskann-disk/benches/benchmarks/aligned_file_reader_bench.rs | Updates benchmark to use aligned_slice + chunks_mut. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #965 +/- ##
==========================================
- Coverage 89.31% 89.30% -0.01%
==========================================
Files 447 448 +1
Lines 83250 83329 +79
==========================================
+ Hits 74354 74419 +65
- Misses 8896 8910 +14
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Poly::from_iter special-cases len == 0 and returns an empty slice rather than an AllocatorError. Update the test to assert Ok + empty slice instead of discarding the result. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Return ANNError instead of panicking on division by zero if num_sectors_per_node or block_size is zero. The constructor currently prevents this, but this guards against corrupt metadata defensively. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #907
This change introduces
AlignedSlice<T>type alias and thealigned_slice()constructor indiskann-quantization::alloc, replacing theAlignedBoxWithSlicewrapper struct fromdiskann-providers. This eliminates an unnecessary abstraction layer and moves aligned allocation to its proper tier.AlignedSlice<T> = Poly<[T], AlignedAllocator>type aliasaligned_slice<T>(capacity, alignment)constructordiskann-disksplit_into_nonoverlapping_mut_sliceswithchunks_mutas_slice/as_mut_slicewith Deref/DerefMutdiskann-providersaligned_slice