-
Notifications
You must be signed in to change notification settings - Fork 468
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
*: split out {controller,compute,storage}-types crates #21554
Conversation
@benesch See "Tips for reviewer" for a bunch of context/questions. If we decide we like the idea and once we hash out names, I'd also love to hear your thoughts on which stakeholders I should pull in from the individual teams. |
I really like the look of the "after" diagram. Unfortunately I'm not going to have time to look at the specifics of this myself! Will follow up on Slack about alternative reviewers. |
@antiguru @teskje @petrosagg Added y'all as individual reviewers on behalf of compute and storage. Let me know if someone else would be more appropriate. This is marked as a draft since I have some open questions (see "Tips for reviewer"), but the concept is ready for review. Happy to answer questions, provide context, etc! I'd love to get signoffs first such that I only have to do the rebase once to land it. :) |
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.
Looks great! Looked through all files, nothing stood out.
DEFAULT_REPLICA_LOGGING_INTERVAL_MICROS, | ||
}; | ||
use mz_controller::clusters::{ReplicaAllocation, ReplicaConfig, ReplicaLogging}; | ||
use mz_controller_types::{ClusterId, DEFAULT_REPLICA_LOGGING_INTERVAL_MICROS}; |
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.
DEFAULT_REPLICA_LOGGING_INTERVAL_MICROS
I was wondering whether we could move this elsewhere, but came to no conclusion!
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.
This const is itself a pub use
of mz_compute_client::controller::DEFAULT_COMPUTE_REPLICA_LOGGING_INTERVAL_MICROS
(moved to mz_compute_types in this PR), which seemed intentional, so I left it alone.
Happy to e.g. remove the re-export and inline it if you think that's better?
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.
It is weird that the controller defines a constant that's only used by the adapter
and sql
crates. Seems like it should be defined in one of those instead?
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.
Compute changes look reasonable to me! I had a couple thoughts, but it's fine to leave them as follow ups for the compute team.
I'm wondering if there is anything we can do to be more aware of crate interdependencies in the future. I think many of us don't spend a lot of thought about adding new dependencies if convenient, and I worry that we might slowly revert to the old spiderweb if we are not careful about it.
src/clusterd/src/lib.rs
Outdated
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.
Just a reminder so you don't forget to remove this again!
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.
Oh whoops! Never even meant to add this to a commit. Done
src/compute-client/src/controller.rs
Outdated
|
||
mod instance; | ||
mod replica; | ||
|
||
pub mod error; | ||
|
||
/// Identifier of a compute instance. | ||
pub type ComputeInstanceId = StorageInstanceId; | ||
|
||
/// Identifier of a replica. | ||
pub type ReplicaId = mz_cluster_client::ReplicaId; |
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.
Can we also move ReplicaId
into mz_compute_types
? It's a bit weird that this is now defined in a different place than ComputeInstanceId
.
Although... thinking about it, we should probably just remove this pub type
entirely and just use mz_cluster_client::ReplicaId
everywhere.
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.
Happy to do either. Pushed the latter
@@ -23,7 +22,7 @@ message ProtoComputeResponse { | |||
message ProtoPeekResponseKind { | |||
mz_proto.ProtoU128 id = 1; | |||
ProtoPeekResponse resp = 2; | |||
map<string, string> otel_ctx = 3; | |||
map<string, string> otel_ctx = 3; |
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.
🙇
ProtoPeekResponseKind peek_response = 2; | ||
ProtoSubscribeResponseKind subscribe_response = 3; | ||
} | ||
} | ||
|
||
message ProtoTrace { |
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 have never understood why this is called "trace". Maybe this is an opportunity to rename it to ProtoUpper
or somesuch? Don't feel obligated if you think that's out of scope!
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.
As I mentioned in the review notes, I suspect we'll end up discarding this commit entirely and doing something else, but if it sticks around happy to do this rename.
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'm wondering if there is anything we can do to be more aware of crate interdependencies in the future. I think many of us don't spend a lot of thought about adding new dependencies if convenient, and I worry that we might slowly revert to the old spiderweb if we are not careful about it.
I'd love to add a lint that prevents certain deps, but that's definitely something I'll have to leave for future skunkworks.
src/clusterd/src/lib.rs
Outdated
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.
Oh whoops! Never even meant to add this to a commit. Done
ProtoPeekResponseKind peek_response = 2; | ||
ProtoSubscribeResponseKind subscribe_response = 3; | ||
} | ||
} | ||
|
||
message ProtoTrace { |
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.
As I mentioned in the review notes, I suspect we'll end up discarding this commit entirely and doing something else, but if it sticks around happy to do this rename.
src/compute-client/src/controller.rs
Outdated
|
||
mod instance; | ||
mod replica; | ||
|
||
pub mod error; | ||
|
||
/// Identifier of a compute instance. | ||
pub type ComputeInstanceId = StorageInstanceId; | ||
|
||
/// Identifier of a replica. | ||
pub type ReplicaId = mz_cluster_client::ReplicaId; |
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.
Happy to do either. Pushed the latter
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 storage-types
split looks good! On storage-operators
, is that crate pulling its weight? Is the idea behind it that it allows iterating on persist_source without recompiling mz-storage
, which is slow?
If yes, we can also go the other way and keep persist_source
in mz-storage
but split out each source to its own crate. Sources already implement a trait so that ought to make things a bit better because each per-source crate will only be recompiled when that particular source changes.
Not a strong opinion on this so if you feel strongly about mz-storage-operators
go ahead with your idea as-is. I'll experiment with splitting sources out in some future skunkworks
Actually, it's almost the opposite in a way. The idea is that it allows iterating on mz-storage-client without invalidating mz-compute. The persist_source commit is easily the least invasive of any of these, so happy to leave it off this PR, discuss async, and do whatever we decide in a followup if you prefer? |
I see. It sounds like |
Removes dep: - mz-sql -> mz-controller
Removes deps: - mz-transform -> mz-compute-client - mz-sql -> mz-compute-client - mz-controller-types -> mz-compute-client
Removes deps: - mz-sql -> mz-storage-client - sqllogictest -> mz-storage-client - mz-compute-types -> mz-storage-client
Removes deps: - mz-cluster -> mz-compute-client - mz-cluster -> mz-storage-client
Removes dep: - mz-compute -> mz-storage-operators - mz-storage-client -> mz-expr
TFTRs, everyone!! I played locally with splitting the storage controller impl out into a new crate instead of splitting the trait out into mz-storage-types, and I do think it's better, but it's non-obvious enough that it's worth going through a round of review. I'm going to pull that out into its own PR so I can go ahead and get this one merged |
This PR has higher risk. Make sure to carefully review the file hotspots. In addition to having a knowledgeable reviewer, it may be useful to add observability and/or a feature flag. What's This?
Buggy File Hotspots: |
A bunch of these crate deps were recently removed in MaterializeInc#21554 in an effort to improve development iteration times (by creating fewer invalidations when changing commonly worked on crates). Keep them from accidentally coming back by adding a CI lint.
A bunch of these crate deps were recently removed in MaterializeInc#21554 in an effort to improve development iteration times (by creating fewer invalidations when changing commonly worked on crates). Keep them from accidentally coming back by adding a CI lint.
A bunch of these crate deps were recently removed in MaterializeInc#21554 in an effort to improve development iteration times (by creating fewer invalidations when changing commonly worked on crates). Keep them from accidentally coming back by adding a CI lint.
This allows changes to implementation code to invalidate fewer crates, hopefully improving dev iteration times.
Notably, mz-sql and mz-transform (both heavyweight) no longer depend on storage-client. As mentioned in the reviewer notes, we could easily add mz-compute to that set.
Real-world timings:
touch src/storage-client/src/lib.rs; cargo check
touch src/storage-client/src/lib.rs; cargo build -p mz-environmentd -p mz-clusterd --lib
touch src/storage-client/src/lib.rs; cargo build --bin environmentd --bin clusterd
Deps above mz-storage-client (before)
Deps above mz-storage-client (after)
Motivation
Tips for reviewer
Opening as a draft because there's some things to work out. Also, I got a touch sloppy with the commit hygiene and import blocks, I'll go back and tighten that up if we decide that this is desirable and if/when the final names are decided.
I feel pretty good about the foo-types model:
foo-types
,foo-service
(interface),foo-concrete
model.foo-service
corresponds to ourmz-foo-client
andfoo-concrete
corresponds to ourmz-foo
.Names that are more or less a strawman at this point:
Intuition for the various names and what should live in them:
Checklist
$T ⇔ Proto$T
mapping (possibly in a backwards-incompatible way), then it is tagged with aT-proto
label.