Skip to content

Test and fixes for concurrent updates to vectors - #2032

Merged
kevin-montrose merged 28 commits into
mainfrom
users/kmontrose/VADDUpdates
Oct 7, 2026
Merged

kevin-montrose merged 28 commits into
mainfrom
users/kmontrose/VADDUpdates

Conversation

@kevin-montrose

@kevin-montrose kevin-montrose commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Tests:

  • VADD updates to elements already in a Vector Set
  • Replication of concurrent VADD updates
  • Replication of concurrent VREM and VADD
  • Replication of concurrent VSETATTR updates

Fixes:

  • Ordering of VADDs during replication replay

This introduces a separate set of element-level locks to guarantee order in AOF matches order actually applied to log. It also splits VADD replays into multiple channels (in addition to the existing multiple tasks) to guarantee element updates on replicas are applied in AOF order.

TODO:

  • VADD returns 1 on updates, needs to return 0; this requires a fix on the DiskANN side
  • Perf comparison tests for VADD to measure impact of new locks
  • Update vector-set.md

New locking introduces basically no overhead when not contended.

Benchmark is 50 serial VADDs of 128-dimension vectors.

BenchmarkDotNet v0.15.8, Windows 11 (10.0.26200.8893/25H2/2025Update/HudsonValley2)
Intel Xeon W-2235 CPU 3.80GHz (Max: 3.79GHz), 1 CPU, 12 logical and 6 physical cores
.NET SDK 10.0.302
[Host] : .NET 8.0.29 (8.0.29, 8.0.2926.32403), X64 RyuJIT x86-64-v4
.NET 10 : .NET 10.0.10 (10.0.10, 10.0.1026.32716), X64 RyuJIT x86-64-v4
.NET 8 : .NET 8.0.29 (8.0.29, 8.0.2926.32403), X64 RyuJIT x86-64-v4

EnvironmentVariables=DOTNET_TieredPGO=0 Concurrent=False Server=False
InvocationCount=1 UnrollFactor=1

Before change (34d14a8)

Method Job Runtime Params Mean Error StdDev
VADD .NET 10 .NET 10.0 AAD 1.125 s 0.0215 s 0.0239 s
VADD .NET 8 .NET 8.0 AAD 1.174 s 0.0232 s 0.0293 s
VADD .NET 10 .NET 10.0 ACL 1.094 s 0.0186 s 0.0146 s
VADD .NET 8 .NET 8.0 ACL 1.161 s 0.0199 s 0.0177 s
VADD .NET 10 .NET 10.0 AOF 1.102 s 0.0188 s 0.0166 s
VADD .NET 8 .NET 8.0 AOF 1.112 s 0.0080 s 0.0071 s
VADD .NET 10 .NET 10.0 None 1.073 s 0.0146 s 0.0130 s
VADD .NET 8 .NET 8.0 None 1.124 s 0.0139 s 0.0123 s

After change (5ce41a7)

Method Job Runtime Params Mean Error StdDev
VADD .NET 10 .NET 10.0 AAD 1.067 s 0.0147 s 0.0123 s
VADD .NET 8 .NET 8.0 AAD 1.108 s 0.0111 s 0.0103 s
VADD .NET 10 .NET 10.0 ACL 1.051 s 0.0167 s 0.0156 s
VADD .NET 8 .NET 8.0 ACL 1.115 s 0.0161 s 0.0151 s
VADD .NET 10 .NET 10.0 AOF 1.041 s 0.0104 s 0.0087 s
VADD .NET 8 .NET 8.0 AOF 1.111 s 0.0159 s 0.0133 s
VADD .NET 10 .NET 10.0 None 1.051 s 0.0181 s 0.0141 s
VADD .NET 8 .NET 8.0 None 1.111 s 0.0124 s 0.0110 s

@kevin-montrose kevin-montrose mentioned this pull request Aug 6, 2026
18 of 19 tasks
…st Environment.ProcessCount updates in flight at once, so 2x overallocation is probably fine
…roach; instead work backwards from expected collisions, and pick with a relatively low collision rate (~5%); update vector-sets.md with scheme
@kevin-montrose
kevin-montrose marked this pull request as ready for review October 7, 2026 14:21
Copilot AI balanced review requested due to automatic review settings October 7, 2026 14:21

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.

Copilot review overview

🟡 Changes recommended

VADD update result handling either reports inserts or, once corrected, prevents updates from being replicated through the AOF.

Review effort: Balanced
Findings: 3 High severity · 2 Medium severity

Open (5)
What changed in this PR

Adds ordering guarantees and tests for concurrent Vector Set updates and replication.

Changes:

  • Adds element-level locking and partitioned replay channels.
  • Distinguishes DiskANN inserts from updates.
  • Adds concurrent update/replication tests and documentation.
File Description
website/​docs/​dev/​vector-sets.md Documents element-ordering locks.
test/​standalone/​Garnet.test.vectorset/​RespVectorSetTests.cs Tests VADD overwrites.
test/​standalone/​Garnet.test.vectorset/​DiskANNServiceTests.cs Updates native result expectations.
test/​cluster/​Garnet.test.cluster.vectorsets/​VectorSets/​ClusterVectorSetTests.cs Adds concurrent replication tests.
libs/​server/​Storage/​Session/​MainStore/​VectorStoreOps.cs Applies element locks to mutations.
libs/​server/​Resp/​Vector/​VectorManager.Replication.cs Partitions VADD replay by element.
libs/​server/​Resp/​Vector/​VectorManager.Locking.cs Implements element-level locks.
libs/​server/​Resp/​Vector/​VectorManager.cs Configures locks and update results.
libs/​server/​Resp/​Vector/​DiskANNService.cs Maps expanded native insert results.
libs/​server/​API/​GarnetApi.cs Removes unnecessary unsafe modifiers.
Directory.Packages.props Upgrades diskann-garnet to 6.0.0.

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

Comment thread libs/server/Resp/Vector/DiskANNService.cs Outdated
Comment thread libs/server/Resp/Vector/VectorManager.cs
Comment thread libs/server/Resp/Vector/VectorManager.cs
Comment thread test/cluster/Garnet.test.cluster.vectorsets/VectorSets/ClusterVectorSetTests.cs Outdated
Comment thread test/cluster/Garnet.test.cluster.vectorsets/VectorSets/ClusterVectorSetTests.cs Outdated
Comment thread libs/server/Resp/Vector/VectorManager.Locking.cs
Comment thread libs/server/Resp/Vector/VectorManager.Locking.cs
@kevin-montrose
kevin-montrose merged commit 6f9b3a8 into main Oct 7, 2026
169 checks passed
@kevin-montrose
kevin-montrose deleted the users/kmontrose/VADDUpdates branch October 7, 2026 18:36
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.

4 participants