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

storage: flatten StorageCommand and StorageResponse #31261

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

petrosagg
Copy link
Contributor

@petrosagg petrosagg commented Jan 31, 2025

Motivation

Tips for reviewer

Each commit flattens one variant

Checklist

  • This PR has adequate test coverage / QA involvement has been duly considered. (trigger-ci for additional test/nightly runs)
  • This PR has an associated up-to-date design doc, is a design doc (template), or is sufficiently small to not require a design.
  • If this PR evolves an existing $T ⇔ Proto$T mapping (possibly in a backwards-incompatible way), then it is tagged with a T-proto label.
  • If this PR will require changes to cloud orchestration or tests, there is a companion cloud PR to account for those changes that is tagged with the release-blocker label (example).
  • If this PR includes major user-facing behavior changes, I have pinged the relevant PM to schedule a changelog post.

@petrosagg petrosagg requested a review from teskje January 31, 2025 14:52
@petrosagg petrosagg requested a review from a team as a code owner January 31, 2025 14:52
@petrosagg petrosagg force-pushed the flatten-storage-command-response branch from 58bd1a6 to 6a9c057 Compare February 5, 2025 14:02
Signed-off-by: Petros Angelatos <[email protected]>
Copy link
Contributor

@teskje teskje left a comment

Choose a reason for hiding this comment

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

LGTM!

self.pending_table_handle_drops_tx
.send(dropped_id)
.expect("ourselves are not dropped");
if !self.pending_table_handle_drops_rx.is_empty() {
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

Comment on lines +1891 to +1893
// Take the allocation so that we can call mut receiver functions in the loop. We put it
// back at the end of the loop.
let mut stashed_responses = std::mem::take(&mut self.stashed_responses);
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe we shouldn't? If we drop the allocation instead, we don't have to worry about it ever getting large. Keeping it lets us safe some allocation overhead, but is that really relevant in this code?

updated_frontiers = Some(Response::FrontierUpdates(updates));
StorageResponse::FrontierUpper(id, upper) => {
let update = (id, upper);
self.update_write_frontiers(std::slice::from_ref(&update));
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks like Controller::update_write_frontiers is now only called with a single update everywhere, so you could rename it to update_write_frontier and remove its loop.

/// A list of statistics updates, currently only for sources.
StatisticsUpdates(Vec<SourceStatisticsUpdate>, Vec<SinkStatisticsUpdate>),
/// A list of status updates for sources and sinks. Periodically sent from
/// A status updates for a source or a sink. Periodically sent from
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
/// A status updates for a source or a sink. Periodically sent from
/// A status update for a source or a sink. Periodically sent from

@@ -146,7 +145,7 @@ impl<T> StorageCommand<T> {
| InitializationComplete
| AllowWrites
| UpdateConfiguration(_)
| AllowCompaction(_) => false,
| AllowCompaction(_, _) => false,
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you know you can use .. on tuple variants too? Not important at all, but I found this neat when I learned about it :)

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