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

pageserver: do vectored read on each dio-aligned section once #8763

Merged
merged 29 commits into from
Aug 28, 2024

Conversation

yliang412
Copy link
Contributor

@yliang412 yliang412 commented Aug 20, 2024

Part of #8130, closes #8719.

Problem

Currently, vectored blob io only coalesce blocks if they are immediately adjacent to each other. When we switch to Direct IO, we need a way to coalesce blobs that are within the dio-aligned boundary but has gap between them.

Summary of changes

  • Introduces a VectoredReadCoalesceMode for VectoredReadPlanner and StreamingVectoredReadPlanner which has two modes:
    • AdjacentOnly (current implementation)
    • Chunked(<alignment requirement>)
  • New ChunkedVectorBuilder that considers batching dio-align-sized read, the start and end of the vectored read will respect stx_dio_offset_align / stx_dio_mem_align (vectored_read.start and vectored_read.blobs_at.first().start_offset will be two different value).
  • Since we break the assumption that blobs within single VectoredRead are next to each other (implicit end offset), we start to store blob end offsets in the VectoredRead.
  • Adapted existing tests to run in both VectoredReadCoalesceMode.
  • The io alignment can also be live configured at runtime.

Testing

See #8779 for a matrix build of the regression test with alignment requirement = [1, 512].

Performance

Benchmark Results

TLDR: No significant difference between using different chunk sizes.

Rollout

  • The adjacent-only merge is enabled by default (io_buffer_alignment=0).
  • Run Rust unittest running with alignment requirement = [0, 1, 512].

We will test the new chunked vectored read code path in pre-prod later this week after release.

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

@yliang412 yliang412 changed the title Yuchen/vectored read chunk coalesce [WIP] vectored read chunk coalesce Aug 20, 2024
@github-actions github-actions bot added the external A PR or Issue is created by an external user label Aug 20, 2024
Copy link

github-actions bot commented Aug 20, 2024

3780 tests run: 3674 passed, 0 failed, 106 skipped (full report)


Code coverage* (full report)

  • functions: 32.3% (7328 of 22654 functions)
  • lines: 50.4% (59285 of 117523 lines)

* collected from Rust tests only


The comment gets automatically updated with the latest test results
2443e9a at 2024-08-28T14:18:55.634Z :recycle:

@yliang412 yliang412 removed the external A PR or Issue is created by an external user label Aug 20, 2024
@yliang412 yliang412 changed the title [WIP] vectored read chunk coalesce pageserver: do vectored read on each dio-aligned section once Aug 20, 2024
@yliang412 yliang412 self-assigned this Aug 20, 2024
@yliang412 yliang412 added the c/storage/pageserver Component: storage: pageserver label Aug 20, 2024
@yliang412 yliang412 marked this pull request as ready for review August 20, 2024 14:30
@yliang412 yliang412 requested a review from a team as a code owner August 20, 2024 14:30
@yliang412 yliang412 requested review from skyzh, problame and VladLazar and removed request for a team August 20, 2024 14:30
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
@yliang412 yliang412 force-pushed the yuchen/vectored-read-chunk-coalesce branch from 0af8e83 to ea5efeb Compare August 20, 2024 19:01
@yliang412 yliang412 requested review from a team as code owners August 20, 2024 19:01
@yliang412 yliang412 requested review from cloneable and hlinnaka and removed request for a team August 20, 2024 19:01
@yliang412 yliang412 changed the base branch from problame/inmemory-layer-offset-u32 to main August 20, 2024 19:01
@yliang412 yliang412 marked this pull request as draft August 20, 2024 19:02
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Copy link
Contributor

@VladLazar VladLazar left a comment

Choose a reason for hiding this comment

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

Generally looks good


Are we supporting these two modes to allow for a staged cut-over to dio?

pageserver/src/tenant/vectored_blob_io.rs Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
@yliang412
Copy link
Contributor Author

Are we supporting these two modes to allow for a staged cut-over to dio?

Currently doing perf testing to see if this is mergable without the actual O_DIRECT changes. I will report back findings once I'm done.

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.

This review pertains to code that is taken by the Adjacent path, i.e., this review is to ensure we're not regressing anything.

pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
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.

Reviewed the ChunkedVectoredReadBuilderInner.

Seems correct, some style comments.

pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
pageserver/src/tenant/vectored_blob_io.rs Outdated Show resolved Hide resolved
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
@yliang412 yliang412 force-pushed the yuchen/vectored-read-chunk-coalesce branch from dff338c to fe2393c Compare August 25, 2024 20:31
yliang412 and others added 5 commits August 26, 2024 16:37
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Signed-off-by: Yuchen Liang <yuchen@neon.tech>
@yliang412 yliang412 marked this pull request as ready for review August 26, 2024 21:33
@yliang412 yliang412 enabled auto-merge (squash) August 28, 2024 13:11
@yliang412 yliang412 merged commit a889a49 into main Aug 28, 2024
70 checks passed
@yliang412 yliang412 deleted the yuchen/vectored-read-chunk-coalesce branch August 28, 2024 14:54
yliang412 added a commit that referenced this pull request Aug 28, 2024
Part of #8130, closes #8719.

## Problem

Currently, vectored blob io only coalesce blocks if they are immediately
adjacent to each other. When we switch to Direct IO, we need a way to
coalesce blobs that are within the dio-aligned boundary but has gap
between them.

## Summary of changes

- Introduces a `VectoredReadCoalesceMode` for `VectoredReadPlanner` and
`StreamingVectoredReadPlanner` which has two modes:
  - `AdjacentOnly` (current implementation)
  - `Chunked(<alignment requirement>)`
- New `ChunkedVectorBuilder` that considers batching `dio-align`-sized
read, the start and end of the vectored read will respect
`stx_dio_offset_align` / `stx_dio_mem_align` (`vectored_read.start` and
`vectored_read.blobs_at.first().start_offset` will be two different
value).
- Since we break the assumption that blobs within single `VectoredRead`
are next to each other (implicit end offset), we start to store blob end
offsets in the `VectoredRead`.
- Adapted existing tests to run in both `VectoredReadCoalesceMode`.
- The io alignment can also be live configured at runtime.

Signed-off-by: Yuchen Liang <yuchen@neon.tech>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c/storage/pageserver Component: storage: pageserver
Projects
None yet
Development

Successfully merging this pull request may close these issues.

vectored read: only read each stx_dio_offset_align/stx_dio_mem_align-sized section once
3 participants