-
Notifications
You must be signed in to change notification settings - Fork 447
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(page_service): timeout-based batching of requests #9321
Conversation
2fd0a67
to
14883d2
Compare
14883d2
to
96afede
Compare
5490 tests run: 5264 passed, 0 failed, 226 skipped (full report)Code coverage* (full report)
* collected from Rust tests only The comment gets automatically updated with the latest test results
2bea398 at 2024-11-18T20:25:20.479Z :recycle: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The terminology is 50% debounce 50% batching.
I think batching
is better, let's adjust the names.
As a person who doesn't mind wordy names, page_service_server_side_batching
is how I'd call the functionality / code module.
Maybe server_side_batch_timeout
for the config flag?
And BatchedFeMessageS
instead of DebouncedFeMessage
for the type?
During the hackathon, and now, I wonder(ed) whether we could refactor the batching loop into a Stream / $itertoolsadapter
Like, at the start of handle_pagerequests
, split the pgb
into reading and writing end (maybe fake that using Arc<Mutex<Pgb>>
).
The wrap the reading end into the thing that implements Stream, spitting out DebouncedFeMessage
as the strema item.
Orthogonal to that, can we please move the batching into a helper function so the high-level control flow of handle_pagerequests
remains clear-ish?
I flagged a couple of places that warn! aggressively.
I actually don't know if we log getpage errors. If we do, then I think it's fine to just leave these warn!
messages & dismiss the conversation.
You're right. I'll touch up the names.
I also wondered about this while going through the code, but resisted the temptation to rewrite.
Sure, I'll give it a go. |
The refactor is straightforward, but we also fix a bug. Previously, a batch could have been empty if handling the first message resulted in an error (would have panicked). This has been fixed by including errors in the current batch.
Conflicts: Pageserver config was also updated in main
We already log get page errors the pagestream level and on the ingest path.
Switch to over to using Vec for the `Vec::spare_capacity_mut` interface. Fill the `MayebUninit` slots carefully and `Vec::set_len` at the end.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see a lot of plumbing-through of the server_side_batch_timeout
variable.
Personally I wouldn't mind just plumbing through the &'static PageServerConf
.
Or building a PageServiceConf
object out of PageServerConf.
Easily punt-able though.
I think the only two things I'm hard-requesting-changes for is the use of smallvec<1> for the return value of read_batch_from_connection
, and the elimination of the panic!(unsupported)
Smallvec 1.13.2 contains [an UB fix](servo/rust-smallvec#345). Upstream opened [a request](rustsec/advisory-db#1960) for this in the advisory-db but it never got acted upon. Found while working on #9321.
Smallvec 1.13.2 contains [an UB fix](servo/rust-smallvec#345). Upstream opened [a request](rustsec/advisory-db#1960) for this in the advisory-db but it never got acted upon. Found while working on #9321.
…-get-page-requests Conflicts (all syntactic, not semantic) libs/pageserver_api/src/config.rs pageserver/Cargo.toml pageserver/src/config.rs pageserver/src/page_service.rs pageserver/src/pgdatadir_mapping.rs
…n of PageReconstructError=>PageStreamError for case of Timeline cancellation
This PR adds two benchmark to demonstrate the effect of server-side getpage request batching added in #9321. For the CPU usage, I found the the `prometheus` crate's built-in CPU usage accounts the seconds at integer granularity. That's not enough you reduce the target benchmark runtime for local iteration. So, add a new `libmetrics` metric and report that. The benchmarks are disabled because [on our benchmark nodes, timer resolution isn't high enough](https://neondb.slack.com/archives/C059ZC138NR/p1732264223207449). They work (no statement about quality) on my bare-metal devbox. They will be refined and enabled once we find a fix. Candidates at time of writing are: - #9822 - #9851 Refs: - Epic: #9376 - Extracted from #9792
Problem
We don't take advantage of queue depth generated by the compute
on the pageserver. We can process getpage requests more efficiently
by batching them.
Summary of changes
Batch up incoming getpage requests that arrive within a configurable time window (
server_side_batch_timeout
).Then process the entire batch via one
get_vectored
timeline operation.By default, no merging takes place.
Testing