Skip to content

Make UnalignedSlice Send and Sync. - #1348

Open
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
mainfrom
mhildebr/unaligned-slice
Open

Make UnalignedSlice Send and Sync.#1348
Mark Hildebrand (hildebrandmw) wants to merge 1 commit into
mainfrom
mhildebr/unaligned-slice

Conversation

@hildebrandmw

Copy link
Copy Markdown
Contributor

Needed for the inmem2 quantization work.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR makes diskann-vector::UnalignedSlice explicitly Send and Sync (with T: Sync bounds), enabling it to be moved/shared across threads for upcoming in-memory quantization work.

Changes:

  • Add unsafe impl Send for UnalignedSlice<'_, T> where T: Sync.
  • Add unsafe impl Sync for UnalignedSlice<'_, T> where T: Sync.
Suppressed comments (1)

diskann-vector/src/unaligned.rs:31

  • The SAFETY comment for the Sync impl currently refers to "&T is send"; for Sync it’s clearer to justify the bound directly as T: Sync (equivalently, &T: Send). This helps avoid confusion between the Send and Sync auto-traits.
/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be shared with other threads when `&T`
/// is send, implying the bound `T: Sync`.
unsafe impl<T> Sync for UnalignedSlice<'_, T> where T: Sync {}

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +25 to +27
/// SAFETY: `UnalignedSlice` is like a `&[T]`: it can be sent to other threads when `&T` is
/// send - implying the bound `T: Sync`.
unsafe impl<T> Send for UnalignedSlice<'_, T> where T: Sync {}
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.55%. Comparing base (860cf47) to head (3a74727).

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1348      +/-   ##
==========================================
- Coverage   91.55%   91.55%   -0.01%     
==========================================
  Files         521      521              
  Lines      100347   100347              
==========================================
- Hits        91877    91874       -3     
- Misses       8470     8473       +3     
Flag Coverage Δ
miri 91.55% <ø> (-0.01%) ⬇️
unittests 91.23% <ø> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
diskann-vector/src/unaligned.rs 90.90% <ø> (ø)

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants