Skip to content

test(index): stabilize simple index nearest centroid test#7723

Merged
BubbleCal merged 1 commit into
mainfrom
yang/stabilize-simple-index-test
Jul 10, 2026
Merged

test(index): stabilize simple index nearest centroid test#7723
BubbleCal merged 1 commit into
mainfrom
yang/stabilize-simple-index-test

Conversation

@BubbleCal

@BubbleCal BubbleCal commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Bug Fix

What is the bug?

test_simple_index_nearest_centroid builds a small HNSW index in parallel and then requires an exact nearest-centroid result. HNSW node insertion mutates the shared graph concurrently, so Rayon scheduling can produce different graph topologies even though node-level RNG is seeded.

What incorrect behavior does the bug cause?

The approximate search occasionally fails the strict id == 42 assertion and returns a nearby centroid such as 43 or 44. This makes the test flaky, especially under CPU contention, without indicating a production regression.

How does this PR fix the problem?

Build the test's 100-point HNSW index inside a dedicated single-thread Rayon pool. This preserves the exact assertions while making graph construction deterministic. Production index construction and the binary nearest-centroid test are unchanged.

Validation

  • cargo test -p lance-index test_simple_index_nearest_centroid -- --nocapture
  • 3,000 concurrent stress-test runs with 16 processes and RAYON_NUM_THREADS=8: 0 failures
  • cargo fmt --all -- --check
  • cargo clippy -p lance-index --tests -- -D warnings

Summary by CodeRabbit

  • Tests
    • Updated vector index testing to run index construction within a controlled single-threaded environment.
    • No user-facing behavior changes.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: ec8dff2a-ad17-435b-8645-598cc63a2e66

📥 Commits

Reviewing files that changed from the base of the PR and between 1946a5a and 8c9f7e6.

📒 Files selected for processing (1)
  • rust/lance-index/src/vector/utils.rs

📝 Walkthrough

Walkthrough

Changes

Vector index test execution

Layer / File(s) Summary
Run index construction in Rayon
rust/lance-index/src/vector/utils.rs
The nearest-centroid test creates a single-thread Rayon pool and invokes build_index through thread_pool.install(...). Rayon’s ThreadPoolBuilder is imported for the test setup.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the test-focused change to stabilize the nearest centroid simple index test.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch yang/stabilize-simple-index-test

Comment @coderabbitai help to get the list of available commands.

@github-actions github-actions Bot added A-index Vector index, linalg, tokenizer chore labels Jul 10, 2026
@BubbleCal
BubbleCal marked this pull request as ready for review July 10, 2026 11:34
@codecov

codecov Bot commented Jul 10, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@westonpace westonpace left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I did not realize we were still using rayon!

@BubbleCal

Copy link
Copy Markdown
Contributor Author

I did not realize we were still using rayon!

lol we should remove it

@BubbleCal
BubbleCal merged commit 1ce1764 into main Jul 10, 2026
35 checks passed
@BubbleCal
BubbleCal deleted the yang/stabilize-simple-index-test branch July 10, 2026 16:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-index Vector index, linalg, tokenizer chore

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants