Repository navigation
Commit 3cb50e7
perf(sei-db/view): release a cache-miss reader before installing its value (#4764)
**Problem**
- A FlatKV read that misses the view's read cache waits for
`injectValueUnlocked` to take the cache's write lock and install the
value before it gets its result. Under read-heavy load that lock is
contended, so every cache miss also pays for the lock wait.
**Change**
- A successful miss result is sent to its waiter before the value is
installed. A reader that arrives in between still finds the entry
scheduled and takes the value from the same channel.
- A failed read is still released only after the cache is taken out of
service.
**Impact**
- Removes the install's lock wait from every cache-miss read on the
execution path. Benchmarked on CLOB together with #4765 and the off-loop
overlay index, the three changes raised throughput by about 8%.
**Risk**
- Ordering only: the waiter gets the value slightly before later readers
can see it in the cache. Later readers already handle that state
(scheduled entry, value on the channel), and `ResolveBatchUnlocked` uses
the same ordering.
**Tests**
- `sei-db/db_engine/view/...` and `sei-db/state_db/sc/flatkv/...` pass
with `-race`.
Co-authored-by: Cursor <cursoragent@cursor.com>1 parent 9ef78ac commit 3cb50e7
1 file changed
Lines changed: 10 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
398 | 398 | | |
399 | 399 | | |
400 | 400 | | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
401 | 408 | | |
402 | 409 | | |
403 | 410 | | |
| |||
430 | 437 | | |
431 | 438 | | |
432 | 439 | | |
433 | | - | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
434 | 443 | | |
435 | 444 | | |
436 | 445 | | |
| |||
0 commit comments