Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kv: only declare abort span key when txn has locks #136523

Merged

Conversation

nvanbenschoten
Copy link
Member

Informs #122719.

This commit updates DeclareKeysForBatch to only declare the abort span key when the transaction has acquired locks and will need to check the abort span. We were previously declaring the abort span key for all batches, even if we did not intend to check the abort span.

This is a short-term patch until we get around to reworking abort span access more thoroughly (see #122719).

name                                           old time/op    new time/op    delta
Sysbench/KV/1node_local/oltp_read_only-10         334µs ± 4%     325µs ± 4%  -2.63%  (p=0.035 n=10+9)
Sysbench/KV/1node_local/oltp_read_write-10        863µs ± 9%     860µs ±15%    ~     (p=0.661 n=10+9)
Sysbench/KV/1node_local/oltp_point_select-10     15.6µs ± 4%    15.9µs ±12%    ~     (p=0.529 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10       1.88ms ±26%    1.80ms ± 5%    ~     (p=1.000 n=10+9)
Sysbench/SQL/1node_local/oltp_read_write-10      4.22ms ± 5%    4.18ms ±11%    ~     (p=0.400 n=9+10)
Sysbench/SQL/1node_local/oltp_point_select-10     114µs ± 5%     120µs ±21%    ~     (p=0.796 n=10+10)

name                                           old alloc/op   new alloc/op   delta
Sysbench/KV/1node_local/oltp_read_write-10        487kB ± 0%     484kB ± 1%  -0.55%  (p=0.011 n=8+9)
Sysbench/KV/1node_local/oltp_read_only-10         260kB ± 0%     259kB ± 1%  -0.50%  (p=0.011 n=8+10)
Sysbench/SQL/1node_local/oltp_point_select-10    27.8kB ± 0%    27.6kB ± 0%  -0.47%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        878kB ± 0%     876kB ± 0%  -0.25%  (p=0.003 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10      1.25MB ± 1%    1.25MB ± 1%    ~     (p=0.146 n=10+8)
Sysbench/KV/1node_local/oltp_point_select-10     4.68kB ± 1%    4.68kB ± 2%    ~     (p=0.474 n=9+9)

name                                           old allocs/op  new allocs/op  delta
Sysbench/KV/1node_local/oltp_read_only-10           522 ± 0%       507 ± 0%  -2.72%  (p=0.000 n=10+10)
Sysbench/KV/1node_local/oltp_read_write-10        1.51k ± 0%     1.50k ± 0%  -0.92%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_point_select-10       238 ± 0%       237 ± 0%  -0.42%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        4.76k ± 0%     4.74k ± 0%  -0.39%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10       7.55k ± 0%     7.53k ± 0%  -0.24%  (p=0.003 n=10+10)
Sysbench/KV/1node_local/oltp_point_select-10       29.0 ± 0%      29.0 ± 0%    ~     (all equal)

Release note: None

Informs cockroachdb#122719.

This commit updates DeclareKeysForBatch to only declare the abort span
key when the transaction has acquired locks and will need to check the
abort span. We were previously declaring the abort span key for all
batches, even if we did not intend to check the abort span.

This is a short-term patch until we get around to reworking abort span
access more thoroughly (see cockroachdb#122719).

```
name                                           old time/op    new time/op    delta
Sysbench/KV/1node_local/oltp_read_only-10         334µs ± 4%     325µs ± 4%  -2.63%  (p=0.035 n=10+9)
Sysbench/KV/1node_local/oltp_read_write-10        863µs ± 9%     860µs ±15%    ~     (p=0.661 n=10+9)
Sysbench/KV/1node_local/oltp_point_select-10     15.6µs ± 4%    15.9µs ±12%    ~     (p=0.529 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10       1.88ms ±26%    1.80ms ± 5%    ~     (p=1.000 n=10+9)
Sysbench/SQL/1node_local/oltp_read_write-10      4.22ms ± 5%    4.18ms ±11%    ~     (p=0.400 n=9+10)
Sysbench/SQL/1node_local/oltp_point_select-10     114µs ± 5%     120µs ±21%    ~     (p=0.796 n=10+10)

name                                           old alloc/op   new alloc/op   delta
Sysbench/KV/1node_local/oltp_read_write-10        487kB ± 0%     484kB ± 1%  -0.55%  (p=0.011 n=8+9)
Sysbench/KV/1node_local/oltp_read_only-10         260kB ± 0%     259kB ± 1%  -0.50%  (p=0.011 n=8+10)
Sysbench/SQL/1node_local/oltp_point_select-10    27.8kB ± 0%    27.6kB ± 0%  -0.47%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        878kB ± 0%     876kB ± 0%  -0.25%  (p=0.003 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10      1.25MB ± 1%    1.25MB ± 1%    ~     (p=0.146 n=10+8)
Sysbench/KV/1node_local/oltp_point_select-10     4.68kB ± 1%    4.68kB ± 2%    ~     (p=0.474 n=9+9)

name                                           old allocs/op  new allocs/op  delta
Sysbench/KV/1node_local/oltp_read_only-10           522 ± 0%       507 ± 0%  -2.72%  (p=0.000 n=10+10)
Sysbench/KV/1node_local/oltp_read_write-10        1.51k ± 0%     1.50k ± 0%  -0.92%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_point_select-10       238 ± 0%       237 ± 0%  -0.42%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        4.76k ± 0%     4.74k ± 0%  -0.39%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10       7.55k ± 0%     7.53k ± 0%  -0.24%  (p=0.003 n=10+10)
Sysbench/KV/1node_local/oltp_point_select-10       29.0 ± 0%      29.0 ± 0%    ~     (all equal)
```

Release note: None
@nvanbenschoten nvanbenschoten added the o-perf-efficiency Related to performance efficiency label Dec 2, 2024
@nvanbenschoten nvanbenschoten requested a review from tbg December 2, 2024 21:10
@nvanbenschoten nvanbenschoten requested a review from a team as a code owner December 2, 2024 21:10
Copy link

blathers-crl bot commented Dec 2, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@nvanbenschoten
Copy link
Member Author

TFTR!

bors r+

craig bot pushed a commit that referenced this pull request Dec 3, 2024
136523: kv: only declare abort span key when txn has locks r=nvanbenschoten a=nvanbenschoten

Informs #122719.

This commit updates `DeclareKeysForBatch` to only declare the abort span key when the transaction has acquired locks and will need to check the abort span. We were previously declaring the abort span key for all batches, even if we did not intend to check the abort span.

This is a short-term patch until we get around to reworking abort span access more thoroughly (see #122719).

```
name                                           old time/op    new time/op    delta
Sysbench/KV/1node_local/oltp_read_only-10         334µs ± 4%     325µs ± 4%  -2.63%  (p=0.035 n=10+9)
Sysbench/KV/1node_local/oltp_read_write-10        863µs ± 9%     860µs ±15%    ~     (p=0.661 n=10+9)
Sysbench/KV/1node_local/oltp_point_select-10     15.6µs ± 4%    15.9µs ±12%    ~     (p=0.529 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10       1.88ms ±26%    1.80ms ± 5%    ~     (p=1.000 n=10+9)
Sysbench/SQL/1node_local/oltp_read_write-10      4.22ms ± 5%    4.18ms ±11%    ~     (p=0.400 n=9+10)
Sysbench/SQL/1node_local/oltp_point_select-10     114µs ± 5%     120µs ±21%    ~     (p=0.796 n=10+10)

name                                           old alloc/op   new alloc/op   delta
Sysbench/KV/1node_local/oltp_read_write-10        487kB ± 0%     484kB ± 1%  -0.55%  (p=0.011 n=8+9)
Sysbench/KV/1node_local/oltp_read_only-10         260kB ± 0%     259kB ± 1%  -0.50%  (p=0.011 n=8+10)
Sysbench/SQL/1node_local/oltp_point_select-10    27.8kB ± 0%    27.6kB ± 0%  -0.47%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        878kB ± 0%     876kB ± 0%  -0.25%  (p=0.003 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10      1.25MB ± 1%    1.25MB ± 1%    ~     (p=0.146 n=10+8)
Sysbench/KV/1node_local/oltp_point_select-10     4.68kB ± 1%    4.68kB ± 2%    ~     (p=0.474 n=9+9)

name                                           old allocs/op  new allocs/op  delta
Sysbench/KV/1node_local/oltp_read_only-10           522 ± 0%       507 ± 0%  -2.72%  (p=0.000 n=10+10)
Sysbench/KV/1node_local/oltp_read_write-10        1.51k ± 0%     1.50k ± 0%  -0.92%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_point_select-10       238 ± 0%       237 ± 0%  -0.42%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_only-10        4.76k ± 0%     4.74k ± 0%  -0.39%  (p=0.000 n=10+10)
Sysbench/SQL/1node_local/oltp_read_write-10       7.55k ± 0%     7.53k ± 0%  -0.24%  (p=0.003 n=10+10)
Sysbench/KV/1node_local/oltp_point_select-10       29.0 ± 0%      29.0 ± 0%    ~     (all equal)
```

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
@craig
Copy link
Contributor

craig bot commented Dec 3, 2024

Build failed:

@nvanbenschoten
Copy link
Member Author

Flaked on #136582.

bors r+

@craig craig bot merged commit 5ec22a5 into cockroachdb:master Dec 3, 2024
23 checks passed
@nvanbenschoten nvanbenschoten deleted the nvanbenschoten/abortSpanDeclare branch December 10, 2024 02:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
o-perf-efficiency Related to performance efficiency
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants