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

crl-release-24.1: ingest: avoid unnecessary I/O when checking overlap #3620

Merged

Conversation

RaduBerinde
Copy link
Member

This commit sets the upper bound on the level iterator used when checking for overlap. This avoids unnecessarily opening a file that starts after the key range of interest.

This commit sets the upper bound on the level iterator used when
checking for overlap. This avoids unnecessarily opening a file that
starts after the key range of interest.
@RaduBerinde RaduBerinde requested review from jbowens and a team May 15, 2024 01:16
@cockroach-teamcity
Copy link
Member

This change is Reviewable

Copy link
Member Author

@RaduBerinde RaduBerinde left a comment

Choose a reason for hiding this comment

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

Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @jbowens)


ingest.go line 935 at r1 (raw file):

	computeOverlapWithSpans := func(rIter keyspan.FragmentIterator) (bool, error) {
		// NB: The spans surfaced by the fragment iterator are non-overlapping.
		span, err := rIter.SeekGE(bounds.Start)

Not sure this fixes much, I think we'd still open the next file here?


ingest.go line 1109 at r1 (raw file):

		rkeyLevelIter.Init(
			keyspan.SpanIterOptions{}, comparer.Compare, newRangeKeyIter,
			v.Levels[level].Iter(), manifest.Level(level), manifest.KeyTypeRange,

should this be v.RangeKeyLevels?

@RaduBerinde
Copy link
Member Author

ingest.go line 935 at r1 (raw file):

Previously, RaduBerinde wrote…

Not sure this fixes much, I think we'd still open the next file here?

Well.. only when there's another file on the level which range keys

@RaduBerinde
Copy link
Member Author

ingest.go line 935 at r1 (raw file):

Previously, RaduBerinde wrote…

Well.. only when there's another file on the level which range keys

*with range keys

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 all commit messages.
Reviewable status: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @RaduBerinde)


ingest.go line 1109 at r1 (raw file):

Previously, RaduBerinde wrote…

should this be v.RangeKeyLevels?

Good catch, yeah it should be. v.Levels is still correct since it contains a superset of the files in v.RangeKeyLevels, but the keyspanimpl.LevelIter needs to potentially wade through many files with no range keys

Copy link
Member Author

@RaduBerinde RaduBerinde 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: 0 of 2 files reviewed, 2 unresolved discussions (waiting on @jbowens)


ingest.go line 1109 at r1 (raw file):

Previously, jbowens (Jackson Owens) wrote…

Good catch, yeah it should be. v.Levels is still correct since it contains a superset of the files in v.RangeKeyLevels, but the keyspanimpl.LevelIter needs to potentially wade through many files with no range keys

I'll leave it as is here to minimize the changes. Shouldn't be a big deal, the keyspanimpl.LevelIter will filter out files that have no range keys.

@RaduBerinde RaduBerinde merged commit c077435 into cockroachdb:crl-release-24.1 May 17, 2024
10 checks passed
@RaduBerinde RaduBerinde deleted the overlap-upper-bound-24.1 branch May 17, 2024 03:06
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.

None yet

3 participants