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

sstable: perf improvement for ResetForReuse #4081

Merged
merged 1 commit into from
Oct 20, 2024

Conversation

RaduBerinde
Copy link
Member

Resetting iterators takes a non-trivial amount of time (15% in the
RandSeekInSST benchmark). Most of it is because we're copying fairly
large structures by value.

We change ResetForReuse to reset the iterator in-place, and we use
an unsafe trick to clear out only a section of singleLevelIterator.

Benchmark (baseline includes a few other in-flight PRs):

name                              old time/op  new time/op  delta
RandSeekInSST/v4/single-level-10  1.15µs ± 0%  1.02µs ± 1%  -10.84%  (p=0.001 n=7+7)
RandSeekInSST/v4/two-level-10     1.99µs ± 2%  1.71µs ± 2%  -13.85%  (p=0.000 n=8+8)
RandSeekInSST/v5/single-level-10   944ns ± 1%   823ns ± 1%  -12.86%  (p=0.000 n=8+8)
RandSeekInSST/v5/two-level-10     1.44µs ± 1%  1.24µs ± 7%  -13.79%  (p=0.000 n=7+8)

@RaduBerinde RaduBerinde requested a review from a team as a code owner October 19, 2024 20:07
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Resetting iterators takes a non-trivial amount of time (15% in the
RandSeekInSST benchmark). Most of it is because we're copying fairly
large structures by value.

We change `ResetForReuse` to reset the iterator in-place, and we use
an unsafe trick to clear out only a section of `singleLevelIterator`.

Benchmark (baseline includes a few other in-flight PRs):
```
name                              old time/op  new time/op  delta
RandSeekInSST/v4/single-level-10  1.15µs ± 0%  1.02µs ± 1%  -10.84%  (p=0.001 n=7+7)
RandSeekInSST/v4/two-level-10     1.99µs ± 2%  1.71µs ± 2%  -13.85%  (p=0.000 n=8+8)
RandSeekInSST/v5/single-level-10   944ns ± 1%   823ns ± 1%  -12.86%  (p=0.000 n=8+8)
RandSeekInSST/v5/two-level-10     1.44µs ± 1%  1.24µs ± 7%  -13.79%  (p=0.000 n=7+8)
```
Copy link
Collaborator

@jbowens jbowens 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 9 of 9 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @RaduBerinde)

@RaduBerinde RaduBerinde merged commit dacffe5 into cockroachdb:master Oct 20, 2024
23 checks passed
@RaduBerinde RaduBerinde deleted the optimizer-reset branch October 20, 2024 01:17
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.

3 participants