You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
v2.5.11: replace CosmoKvConnection._lock with Microsoft.VisualStudio.
Threading.AsyncReaderWriterLock
The single SemaphoreSlim(1,1) on CosmoKvConnection has been the gating
bottleneck behind every transport optimisation this session — UDS,
binary protocol, client connection pool all invisible against it
because the server-side serialised everything anyway. Two prior v2.5.7
attempts at rolling our own RW lock failed: drain-N-slots starved
writers under sustained read load, writer-priority gate hit subtle
timing races under xUnit parallelism. The Microsoft.VisualStudio.
Threading.AsyncReaderWriterLock is the same primitive Visual Studio's
project-model uses; bounded fairness + cooperative cancellation
already correct.
Wiring:
- QueryAsync → ReadLockAsync (concurrent)
- ExecuteAsync → WriteLockAsync (exclusive)
- BeginTransactionAsync → WriteLockAsync
- CommitAsync → WriteLockAsync
- RollbackAsync → WriteLockAsync
The Executor-side AsyncLocal<IKvAccess?> from v2.5.8 stays in place —
it's the necessary per-call isolation for concurrent reads on the
shared executor. The ConcurrentDictionary<,> swap for the parser
cache stays too.
3 new xUnit tests in Phase30AsyncRWLockTests verify:
1. 32 concurrent SELECTs measurably faster than serial (<70% of
serial time) — the observable that proves the read lock is
non-exclusive.
2. Reader observing COUNT(*) during concurrent INSERTs never sees
count decrease — write/read isolation.
3. Writer not starved under 8 hot reader tasks — the v2.5.7
drain-N attempt hung this test indefinitely.
All 269 CosmoKv driver tests pass (was 266; +3 new). Pipes pool
tests still 10/10. Once this lands on marivil, the binary-protocol +
pool work from v2.5.10 should finally become a measurable win — the
client-side parallelism now actually maps to server-side parallel
execution.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
0 commit comments