Skip to content

kv: don't perform async intent resolution on 1PC with point lock spans#98630

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/externalLockRegress
Mar 15, 2023
Merged

kv: don't perform async intent resolution on 1PC with point lock spans#98630
craig[bot] merged 1 commit intocockroachdb:masterfrom
nvb:nvanbenschoten/externalLockRegress

Conversation

@nvb
Copy link
Copy Markdown
Contributor

@nvb nvb commented Mar 14, 2023

Fixes #98571.

This commit fixes the regression detected in #98571. In that issue, we saw that the bug fix in 86a5852 (#98044) caused a regression in kv0 (and other benchmarks). This was due to a bug in kvserverbase.IntersectSpan, which was considering local point spans to be external to the provided range span.

This commit fixes the bug by not calling kvserverbase.IntersectSpan for point lock spans.

The commit also makes the utility panic instead of silently returning incorrect results. There's an existing TODO on the utility to generalize it. For now, we just make it harder to misuse.

Finally, we add a test that asserts against the presence of async intent resolution after one-phase commits when external intent resolution is not needed.

name                            old time/op    new time/op    delta
KV/Insert/Native/rows=1-10        61.2µs ± 3%    48.9µs ± 3%  -20.10%  (p=0.000 n=8+9)
KV/Insert/Native/rows=10-10       93.3µs ±15%    76.2µs ± 3%  -18.34%  (p=0.000 n=9+9)
KV/Insert/Native/rows=1000-10     2.84ms ±12%    2.42ms ± 4%  -14.97%  (p=0.000 n=9+9)
KV/Insert/Native/rows=100-10       365µs ± 5%     320µs ± 8%  -12.40%  (p=0.000 n=10+9)
KV/Insert/Native/rows=10000-10    27.6ms ± 6%    24.4ms ± 3%  -11.53%  (p=0.000 n=9+9)

name                            old alloc/op   new alloc/op   delta
KV/Insert/Native/rows=1000-10     4.66MB ± 1%    2.76MB ± 1%  -40.89%  (p=0.000 n=9+9)
KV/Insert/Native/rows=100-10       478kB ± 1%     287kB ± 1%  -39.90%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10000-10    54.2MB ± 2%    34.3MB ± 3%  -36.73%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10-10       64.2kB ± 1%    42.1kB ± 1%  -34.39%  (p=0.000 n=10+9)
KV/Insert/Native/rows=1-10        22.1kB ± 1%    17.3kB ± 1%  -21.56%  (p=0.000 n=9+10)

name                            old allocs/op  new allocs/op  delta
KV/Insert/Native/rows=1000-10      21.5k ± 0%     14.7k ± 0%  -31.70%  (p=0.000 n=8+9)
KV/Insert/Native/rows=10000-10      212k ± 0%      146k ± 0%  -31.31%  (p=0.000 n=9+10)
KV/Insert/Native/rows=100-10       2.34k ± 1%     1.61k ± 0%  -31.31%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10-10          392 ± 1%       276 ± 0%  -29.59%  (p=0.000 n=8+8)
KV/Insert/Native/rows=1-10           173 ± 1%       123 ± 0%  -29.04%  (p=0.000 n=9+8)

Release note: None

@nvb nvb requested a review from arulajmani March 14, 2023 21:58
@nvb nvb requested a review from a team as a code owner March 14, 2023 21:58
@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

Copy link
Copy Markdown
Collaborator

@arulajmani arulajmani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:LGTM:

Reviewed 3 of 3 files at r1, all commit messages.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @nvanbenschoten)


-- commits line 19 at r1:
Nice!


pkg/kv/kvserver/replica_write.go line 592 at r1 (raw file):

	var externalLocks []roachpb.Span
	for _, sp := range etArg.LockSpans {
		if len(sp.EndKey) == 0 {

nit: let's add a comment explaining why we're special case handling point locks?


pkg/kv/kvserver/replica_test.go line 6978 at r1 (raw file):

	for _, tc := range []struct {
		intent   roachpb.Span

Should we rename this to "span" and generalize some of the intent commentary below as well?

Fixes cockroachdb#98571.

This commit fixes the regression detected in cockroachdb#98571. In that issue, we saw that
the bug fix in 86a5852 (cockroachdb#98044) caused a regression in kv0 (and other benchmarks).
This was due to a bug in `kvserverbase.IntersectSpan`, which was considering
local point spans to be external to the provided range span.

This commit fixes the bug by not calling `kvserverbase.IntersectSpan` for point lock
spans.

The commit also makes the utility panic instead of silently returning incorrect results.
There's an existing TODO on the utility to generalize it. For now, we just make it harder
to misuse.

Finally, we add a test that asserts against the presence of async intent resolution after
one-phase commits when external intent resolution is not needed.

```
name                            old time/op    new time/op    delta
KV/Insert/Native/rows=1-10        61.2µs ± 3%    48.9µs ± 3%  -20.10%  (p=0.000 n=8+9)
KV/Insert/Native/rows=10-10       93.3µs ±15%    76.2µs ± 3%  -18.34%  (p=0.000 n=9+9)
KV/Insert/Native/rows=1000-10     2.84ms ±12%    2.42ms ± 4%  -14.97%  (p=0.000 n=9+9)
KV/Insert/Native/rows=100-10       365µs ± 5%     320µs ± 8%  -12.40%  (p=0.000 n=10+9)
KV/Insert/Native/rows=10000-10    27.6ms ± 6%    24.4ms ± 3%  -11.53%  (p=0.000 n=9+9)

name                            old alloc/op   new alloc/op   delta
KV/Insert/Native/rows=1000-10     4.66MB ± 1%    2.76MB ± 1%  -40.89%  (p=0.000 n=9+9)
KV/Insert/Native/rows=100-10       478kB ± 1%     287kB ± 1%  -39.90%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10000-10    54.2MB ± 2%    34.3MB ± 3%  -36.73%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10-10       64.2kB ± 1%    42.1kB ± 1%  -34.39%  (p=0.000 n=10+9)
KV/Insert/Native/rows=1-10        22.1kB ± 1%    17.3kB ± 1%  -21.56%  (p=0.000 n=9+10)

name                            old allocs/op  new allocs/op  delta
KV/Insert/Native/rows=1000-10      21.5k ± 0%     14.7k ± 0%  -31.70%  (p=0.000 n=8+9)
KV/Insert/Native/rows=10000-10      212k ± 0%      146k ± 0%  -31.31%  (p=0.000 n=9+10)
KV/Insert/Native/rows=100-10       2.34k ± 1%     1.61k ± 0%  -31.31%  (p=0.000 n=10+10)
KV/Insert/Native/rows=10-10          392 ± 1%       276 ± 0%  -29.59%  (p=0.000 n=8+8)
KV/Insert/Native/rows=1-10           173 ± 1%       123 ± 0%  -29.04%  (p=0.000 n=9+8)
```

Release note: None
@nvb nvb force-pushed the nvanbenschoten/externalLockRegress branch from d70ec06 to 3300ba2 Compare March 15, 2023 02:38
Copy link
Copy Markdown
Contributor Author

@nvb nvb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @arulajmani)


pkg/kv/kvserver/replica_write.go line 592 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

nit: let's add a comment explaining why we're special case handling point locks?

Done.


pkg/kv/kvserver/replica_test.go line 6978 at r1 (raw file):

Previously, arulajmani (Arul Ajmani) wrote…

Should we rename this to "span" and generalize some of the intent commentary below as well?

Good idea. Done.

@nvb
Copy link
Copy Markdown
Contributor Author

nvb commented Mar 15, 2023

bors r=arulajmani

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Mar 15, 2023

Build succeeded:

@craig craig bot merged commit 1b9ebe1 into cockroachdb:master Mar 15, 2023
@nvb nvb deleted the nvanbenschoten/externalLockRegress branch March 15, 2023 03:44
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.

roachperf: regression in kv on 2023/03/10 - multiple benchmarks

3 participants