-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
storage: omit unnecessary seek in
MVCCDelete
Recently, `MVCCDelete` was extended to return a boolean indicating whether an existing, live key was deleted. This relied on passing a `valueFn` callback to `mvccPutInternal()` which inspected the existing value. Unfortunately, this incurs an additional, expensive seek. In the common case when writing above the latest version, `mvccPutInternal` has already read the existing value when synthesizing the meta record, making this additional seek unnecessary. This patch takes a conservative approach, by modifying `mvccPutInternal` to return a boolean indicating whether an existing value was replaced by the put. This is motivated by backport concerns. It does, however, incur an additional read for all write-write conflicts, not just `MVCCDelete`, but this cost is expected to be negligible considering the cost of a transaction refresh. A better solution might be to remove the need for an additional seek with `valueFn` in the common case, which would also benefit e.g. `MVCCConditionalPut` and `MVCCIncrement`, and avoid the read for non-delete writes. This is left for the future. ``` name old time/op new time/op delta MVCCPutDelete_Pebble-24 20.0µs ± 7% 15.5µs ± 3% -22.43% (p=0.008 n=5+5) name old time/op new time/op delta KV/Delete/Native/rows=1-24 153µs ± 6% 146µs ± 6% -4.41% (p=0.009 n=10+10) KV/Delete/Native/rows=10-24 278µs ± 3% 227µs ± 4% -18.22% (p=0.000 n=10+10) KV/Delete/Native/rows=100-24 1.28ms ± 3% 0.86ms ± 4% -33.01% (p=0.000 n=10+10) KV/Delete/Native/rows=1000-24 10.8ms ± 4% 6.0ms ± 6% -44.98% (p=0.000 n=10+10) KV/Delete/Native/rows=10000-24 110ms ± 4% 62ms ± 5% -43.88% (p=0.000 n=10+10) KV/Delete/SQL/rows=1-24 598µs ± 2% 588µs ± 2% -1.62% (p=0.009 n=10+10) KV/Delete/SQL/rows=10-24 753µs ± 3% 701µs ± 2% -6.90% (p=0.000 n=10+10) KV/Delete/SQL/rows=100-24 2.34ms ± 2% 1.77ms ± 1% -24.42% (p=0.000 n=10+9) KV/Delete/SQL/rows=1000-24 26.0ms ± 4% 18.5ms ± 1% -29.08% (p=0.000 n=10+9) KV/Delete/SQL/rows=10000-24 248ms ± 8% 185ms ± 4% -25.40% (p=0.000 n=10+10) ``` Release note: None
- Loading branch information
1 parent
45d609a
commit fbe8852
Showing
1 changed file
with
68 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters