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

feat(pageserver): add k-merge layer iterator with lazy loading #8053

Merged
merged 7 commits into from
Jul 10, 2024

Conversation

skyzh
Copy link
Member

@skyzh skyzh commented Jun 13, 2024

Problem

Part of #8002. This pull request adds a k-merge iterator for bottom-most compaction.

Summary of changes

The current status and test should cover the use case for L0 compaction so that the L0 compaction process can bypass page cache and have a fixed amount of memory usage. The next step is to integrate this with the new bottom-most compaction.

Checklist before requesting a review

  • I have performed a self-review of my code.
  • If it is a core feature, I have added thorough tests.
  • Do we need to implement analytics? if so did you add the relevant metrics to the dashboard?
  • If this PR requires public announcement, mark it with /release-notes label and add several sentences in this section.

Checklist before merging

  • Do not forget to reformat commit message to not include the above checklist

Copy link

github-actions bot commented Jun 13, 2024

3067 tests run: 2952 passed, 0 failed, 115 skipped (full report)


Flaky tests (2)

Postgres 16

  • test_compaction_induced_by_detaches_in_history: release

Postgres 14

Code coverage* (full report)

  • functions: 32.7% (6970 of 21322 functions)
  • lines: 50.1% (54811 of 109372 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
d9e0e29 at 2024-07-09T20:44:56.287Z :recycle:

@skyzh skyzh force-pushed the skyzh/k-merge-again branch from 0e752b5 to 05fd319 Compare June 13, 2024 20:42
@skyzh skyzh force-pushed the skyzh/image-layer-iter branch from b1c8ff6 to 62786da Compare June 24, 2024 19:25
Base automatically changed from skyzh/image-layer-iter to main June 25, 2024 20:49
@skyzh skyzh force-pushed the skyzh/k-merge-again branch from 05fd319 to b4eb0b3 Compare July 1, 2024 17:17
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh changed the title feat(pageserver): add k-merge image layer iterator with lazy loading feat(pageserver): add k-merge layer iterator with lazy loading Jul 1, 2024
@skyzh skyzh marked this pull request as ready for review July 1, 2024 19:05
@skyzh skyzh requested a review from a team as a code owner July 1, 2024 19:05
@skyzh skyzh requested review from arssher and problame July 1, 2024 19:05
Copy link
Contributor

@problame problame left a comment

Choose a reason for hiding this comment

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

Aplogogies for the delayed review!


Why aren't we implementing futures::Stream so we can use peekable instead of the home-grown thing added in this PR?

(Not asking for it to happen in this PR, just generally => maybe let's discuss on Slack)


Requesting some changes, if you disagree let's discuss on Slack . Re-request review once address.

pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/storage_layer/merge_iterator.rs Outdated Show resolved Hide resolved
@skyzh
Copy link
Member Author

skyzh commented Jul 3, 2024

Why aren't we implementing futures::Stream so we can use peekable instead of the home-grown thing added in this PR?

I want to avoid using Stream because it introduces opaque type and cannot be stored in other structs.

@problame
Copy link
Contributor

problame commented Jul 3, 2024

I want to avoid using Stream because it introduces opaque type and cannot be stored in other structs.

What I mean is impl Stream for LayerIter , then by the magic of StreamExt, your LayerIter suddendly has a method peekable() that returns a Peekable<LayerIter>.

No opaque types anywhere.

But, anyway, not asking for it in this PR.

Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh force-pushed the skyzh/k-merge-again branch from 273ee1c to 6bf5532 Compare July 3, 2024 20:09
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh requested a review from problame July 3, 2024 20:17
skyzh and others added 2 commits July 5, 2024 13:09
Co-authored-by: Christian Schwarz <christian@neon.tech>
Signed-off-by: Alex Chi Z <chi@neon.tech>
@skyzh skyzh requested a review from problame July 5, 2024 17:19
@skyzh skyzh merged commit 9f4511c into main Jul 10, 2024
67 checks passed
@skyzh skyzh deleted the skyzh/k-merge-again branch July 10, 2024 18:11
skyzh added a commit that referenced this pull request Jul 15, 2024
Part of #8002. This pull
request adds a k-merge iterator for bottom-most compaction.

## Summary of changes

* Added back lsn_range / key_range in delta layer inner. This was
removed due to #8050, but added
back because iterators need that information to process lazy loading.
* Added lazy-loading k-merge iterator.
* Added iterator wrapper as a unified iterator type for image+delta
iterator.

The current status and test should cover the use case for L0 compaction
so that the L0 compaction process can bypass page cache and have a fixed
amount of memory usage. The next step is to integrate this with the new
bottom-most compaction.

---------

Signed-off-by: Alex Chi Z <chi@neon.tech>
Co-authored-by: Christian Schwarz <christian@neon.tech>
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.

2 participants