Skip to content

Conversation

@jbowens
Copy link
Collaborator

@jbowens jbowens commented May 9, 2024

Rework the merging iterator's handling of range deletions to use the
interleaved range deletion boundary keys to determine when the iterator is
positioned within a level's range deletion. This removes the direct
manipulation of a range deletion keyspan.FragmentIterator from the mergingIter,
delegating that to the child iterator's keyspan.InterleavingIter.

This factoring is a little cleaner and decouples the mergingIter from the
details of range deletion iterators, and in particular, the levelIter's
individual sstables. It also should reduce key comparisons, especially during
scans, by avoiding unnecessary key comparisons with range deletions that are
loaded but outside the keyspace being iterated over.

Close #2863.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@jbowens jbowens force-pushed the rangedel-span branch 4 times, most recently from e9f5888 to 5c24383 Compare May 10, 2024 17:56
@jbowens jbowens marked this pull request as ready for review May 10, 2024 17:56
@jbowens jbowens requested a review from a team as a code owner May 10, 2024 17:56
jbowens

This comment was marked as resolved.

jbowens added 2 commits May 13, 2024 14:37
Rework the merging iterator's handling of range deletions to use the
interleaved range deletion boundary keys to determine when the iterator is
positioned within a level's range deletion. This removes the direct
manipulation of a range deletion keyspan.FragmentIterator from the mergingIter,
delegating that to the child iterator's keyspan.InterleavingIter.

This factoring is a little cleaner and decouples the mergingIter from the
details of range deletion iterators, and in particular, the levelIter's
individual sstables. It also should reduce key comparisons, especially during
scans, by avoiding unnecessary key comparisons with range deletions that are
loaded but outside the keyspace being iterated over.

Close cockroachdb#2863.
jbowens added a commit to jbowens/pebble that referenced this pull request Jan 12, 2026
In 1a2a77b we began interleaving the boundaries of range deletions from
level iterators. This interleaving avoids stepping away from a table until its
range deletions are no longer useful. However, this interleaving required its
own range deletion iterator, necessitating opening two separate range deletion
iterators into the same block.

This commit updates the levelIter implementation to support interleaving range
deletions without using a rangeDelIterSetter callback and adds a new
getTombstone method that may be used to retrieve the tombstone at the current
iterator's position.

In this commit we update the level checker to no longer request its own range
deletion iterator through rangeDelIterSetter. Instead use the levelIter's
getTombstone method to read the current tombstone within each level, avoiding
opening the duplicate range deletion iterator.

This commit is a subset of the changes in the unmerged PR cockroachdb#3600. Future work
will apply the same technique to the merging iterator, allowing ordinary user
iterators to avoid the duplicate range deletion iterator too.
jbowens added a commit to jbowens/pebble that referenced this pull request Jan 12, 2026
In 1a2a77b we began interleaving the boundaries of range deletions from
level iterators. This interleaving avoids stepping away from a table until its
range deletions are no longer useful. However, this interleaving required its
own range deletion iterator, necessitating opening two separate range deletion
iterators into the same block.

This commit updates the levelIter implementation to support interleaving range
deletions without using a rangeDelIterSetter callback and adds a new
getTombstone method that may be used to retrieve the tombstone at the current
iterator's position.

In this commit we update the level checker to no longer request its own range
deletion iterator through rangeDelIterSetter. Instead use the levelIter's
getTombstone method to read the current tombstone within each level, avoiding
opening the duplicate range deletion iterator.

This commit is a subset of the changes in the unmerged PR cockroachdb#3600. Future work
will apply the same technique to the merging iterator, allowing ordinary user
iterators to avoid the duplicate range deletion iterator too.
jbowens added a commit to jbowens/pebble that referenced this pull request Jan 14, 2026
In 1a2a77b we began interleaving the boundaries of range deletions from
level iterators. This interleaving avoids stepping away from a table until its
range deletions are no longer useful. However, this interleaving required its
own range deletion iterator, necessitating opening two separate range deletion
iterators into the same block.

This commit updates the levelIter implementation to support interleaving range
deletions without using a rangeDelIterSetter callback and adds a new
getTombstone method that may be used to retrieve the tombstone at the current
iterator's position.

In this commit we update the level checker to no longer request its own range
deletion iterator through rangeDelIterSetter. Instead use the levelIter's
getTombstone method to read the current tombstone within each level, avoiding
opening the duplicate range deletion iterator.

This commit is a subset of the changes in the unmerged PR cockroachdb#3600. Future work
will apply the same technique to the merging iterator, allowing ordinary user
iterators to avoid the duplicate range deletion iterator too.
jbowens added a commit that referenced this pull request Jan 14, 2026
In 1a2a77b we began interleaving the boundaries of range deletions from
level iterators. This interleaving avoids stepping away from a table until its
range deletions are no longer useful. However, this interleaving required its
own range deletion iterator, necessitating opening two separate range deletion
iterators into the same block.

This commit updates the levelIter implementation to support interleaving range
deletions without using a rangeDelIterSetter callback and adds a new
getTombstone method that may be used to retrieve the tombstone at the current
iterator's position.

In this commit we update the level checker to no longer request its own range
deletion iterator through rangeDelIterSetter. Instead use the levelIter's
getTombstone method to read the current tombstone within each level, avoiding
opening the duplicate range deletion iterator.

This commit is a subset of the changes in the unmerged PR #3600. Future work
will apply the same technique to the merging iterator, allowing ordinary user
iterators to avoid the duplicate range deletion iterator too.
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.

db: consider reworking rangedel, mergingIter and levelIter interactions

2 participants