Skip to content

Keep shared objects off the per-neighbor search path - #833

Merged
tlwillke merged 3 commits into
mainfrom
jv/searcher-shared-line
Nov 25, 2026
Merged

tlwillke merged 3 commits into
mainfrom
jv/searcher-shared-line

Conversation

@tlwillke

@tlwillke tlwillke commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

With several searchers running at once, some JVMs ran graph search 13–22% slower for their whole lifetime. The cause is false sharing. For every scored neighbor, GraphSearcher read shared objects (Bits.ALL and the no-op score tracker) and wrote its own visitedCount. After heap compaction, one worker's searcher could end up on the same cache line as a shared object. Its writes then kept pulling that line away from the other cores.

searchOneLayer now checks once per layer whether the filter accepts everything and whether the tracker is the no-op one, so the per-neighbor path no longer touches shared objects. Visits are counted in the per-layer processor and added to visitedCount once per layer. Results and visit counts are unchanged.

Results

Setup:

  • GNR (48 cores), JDK 22, cohere-english-v3-1M, fused ASH 2-bit.
  • 8 queued workers pinned to 8 cores.
  • 16 fresh JVMs per arm.
  • Each JVM ran one cold pass of 50k queries on a warm index: the 10k held-out queries plus 4 noisy, renormalized copies.
Mean QPS JVMs in slow mode Mean QPS, other JVMs
Before 112.0k 4 of 16 (90.6k–101.6k) 116.6k
After 115.4k 0 of 16 115.8k

Every JVM visited the same number of nodes per query (508.3).

The slow mode is intermittent and appears less often on current main. These runs therefore compare commit 8863c5a with and without the change, where it shows up more readily. Among JVMs that did not go slow, the change was about 0.7% lower, which is close to the noise.

Tests: jvector-tests passes on Ice Lake (8 cores), 131 tests.

searchOneLayer checks once per layer for accept-all filters and the no-op
score tracker, and counts visits in the per-layer processor.
@github-actions

Copy link
Copy Markdown
Contributor

Before you submit for review:

  • Does your PR follow guidelines from CONTRIBUTIONS.md?
  • Did you summarize what this PR does clearly and concisely?
  • Did you include performance data for changes which may be performance impacting?
  • Did you include useful docs for any user-facing changes or features?
  • Did you include useful javadocs for developer oriented changes, explaining new concepts or key changes?
  • Did you rebase your branch onto the latest main for regression testing and PR submission?
  • Did you trigger regression testing via Run Bench Main and review results?
  • Did you adhere to the code formatting guidelines (TBD)
  • Did you group your changes for easy review, providing meaningful descriptions for each commit?
  • Did you ensure that all files contain the correct copyright header?
  • Did you add documentation for this feature to the release notes directory?

If you did not complete any of these, then please explain below.

@tlwillke tlwillke self-assigned this Nov 24, 2026
@tlwillke tlwillke added the bug Something isn't working label Nov 24, 2026
Shorten comments and add the 4.1.0-rc.2 performance note.

@jshook jshook 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.

LGTM

@dian-lun-lin dian-lun-lin 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.

LGTM

@MarkWolters MarkWolters 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.

Just asking for a docs change, looks good otherwise

@tlwillke
tlwillke merged commit a869a30 into main Nov 25, 2026
26 of 27 checks passed
@tlwillke
tlwillke deleted the jv/searcher-shared-line branch November 25, 2026 01:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

4.1.0-rc.2 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants