Skip to content

Restore the ability to have Owned computers. - #1382

Merged
Mark Hildebrand (hildebrandmw) merged 2 commits into
mainfrom
mhildebr/arc
Sep 8, 2026
Merged

Restore the ability to have Owned computers.#1382
Mark Hildebrand (hildebrandmw) merged 2 commits into
mainfrom
mhildebr/arc

Conversation

@hildebrandmw

@hildebrandmw Mark Hildebrand (hildebrandmw) commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

Turns out #1247 was a little premature - we still have some code that is dependent on using Arc<FixedChunkPQTable>. Until a full replacement for PQ is in place, this is a stop-gap to enabled reference counted computers.

The main idea is to introduce

struct Shared<'a, T> {
    Arc(Arc<T>),
    Ref(&'a T),
}

as the container for the FixedChunkPQTable. Types that need to use Arc can use Shared<'static, T>. Existing code can continue to use Shared::Ref.

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.

🟡 Changes recommended

The new Shared unit test contains an invalid pointer comparison (shared.as_ptr() vs Arc::as_ptr()), which will not type-check and should be corrected before merging.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR reintroduces reference-counted ownership for PQ distance/query computers by adding a Shared<'a, T> container (borrowed &T or owned Arc<T>) and threading it through the PQ distance stack and relevant providers/benchmarks, restoring compatibility with code paths that still require Arc<FixedChunkPQTable>.

Changes:

  • Add Shared<'a, T> (Arc-backed “owned” + borrowed ref) to pq::distance and update PQ distance/query computer APIs to accept it.
  • Update PQ distance implementations (L2/IP/Cosine/Dynamic/Multi) and async providers to pass Shared instead of raw &FixedChunkPQTable.
  • Adjust benchmark code to construct Shared when creating PQ query computers.
File summaries
File Description
diskann-providers/src/model/pq/distance/multi.rs Switch MultiTable to store Shared PQ tables and update tests/callers accordingly.
diskann-providers/src/model/pq/distance/mod.rs Introduce the new Shared<'a, T> container and add unit tests.
diskann-providers/src/model/pq/distance/l2.rs Update L2 PQ query computer to hold Shared parent table.
diskann-providers/src/model/pq/distance/innerproduct.rs Update inner product PQ query computer to hold Shared parent table.
diskann-providers/src/model/pq/distance/dynamic.rs Update dynamic PQ query/distance computer constructors and vtable calls to use Shared.
diskann-providers/src/model/pq/distance/cosine.rs Update cosine PQ query computer to hold Shared parent table.
diskann-providers/src/model/graph/provider/async_/memory_quant_vector_provider.rs Wrap PQ table with Shared::Ref when creating computers.
diskann-providers/src/model/graph/provider/async_/fast_memory_quant_vector_provider.rs Wrap PQ table with Shared::Ref when creating computers.
diskann-providers/src/model/graph/provider/async_/experimental/multi_pq_async.rs Update multi-PQ table construction to use Shared::Ref for schemas.
diskann-benchmark/src/exhaustive/product.rs Construct Shared when creating PQ query computers in benchmarks.
Review details
  • Files reviewed: 10/10 changed files
  • Comments generated: 1
  • Review effort level: Lite

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

Comment thread diskann-providers/src/model/pq/distance/mod.rs Outdated
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.53086% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 91.43%. Comparing base (600c2b9) to head (6e59fa7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
diskann-providers/src/model/pq/distance/mod.rs 92.85% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1382      +/-   ##
==========================================
- Coverage   91.55%   91.43%   -0.12%     
==========================================
  Files         521      522       +1     
  Lines      100302   100766     +464     
==========================================
+ Hits        91828    92132     +304     
- Misses       8474     8634     +160     
Flag Coverage Δ
miri 91.43% <97.53%> (-0.12%) ⬇️
unittests 91.22% <97.53%> (-0.01%) ⬇️

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

Files with missing lines Coverage Δ
diskann-benchmark/src/exhaustive/product.rs 83.33% <ø> (ø)
...aph/provider/async_/experimental/multi_pq_async.rs 97.54% <100.00%> (+0.01%) ⬆️
...ovider/async_/fast_memory_quant_vector_provider.rs 97.84% <100.00%> (ø)
...ph/provider/async_/memory_quant_vector_provider.rs 97.43% <100.00%> (ø)
diskann-providers/src/model/pq/distance/cosine.rs 98.75% <100.00%> (ø)
diskann-providers/src/model/pq/distance/dynamic.rs 97.33% <100.00%> (+0.07%) ⬆️
...nn-providers/src/model/pq/distance/innerproduct.rs 100.00% <100.00%> (ø)
diskann-providers/src/model/pq/distance/l2.rs 100.00% <100.00%> (ø)
diskann-providers/src/model/pq/distance/multi.rs 98.03% <100.00%> (+0.02%) ⬆️
diskann-providers/src/model/pq/distance/mod.rs 92.85% <92.85%> (ø)

... and 43 files with indirect coverage changes

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

@hildebrandmw
Mark Hildebrand (hildebrandmw) merged commit 2e1fc7e into main Sep 8, 2026
30 checks passed
Mark Hildebrand (hildebrandmw) added a commit that referenced this pull request Sep 8, 2026
# Breaking Changes since 0.57.0
• Restored support for reference-counted (`Arc`) PQ distance tables via
a new internal `Shared<'a, FixedChunkPQTable>` enum, unblocking code
paths that still depend on owned/shared tables ahead of a full PQ
replacement. (#1382)

## What's Changed
* Restore the ability to have `Owned` computers. by @hildebrandmw in
#1382

**Full Changelog**:
v0.57.0...v0.58.0

Co-authored-by: Mark Hildebrand <mhildebrand@microsoft.com>
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.

5 participants