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

eliminate large enum in prost #19906

Open
xxchan opened this issue Dec 24, 2024 · 1 comment
Open

eliminate large enum in prost #19906

xxchan opened this issue Dec 24, 2024 · 1 comment

Comments

@xxchan
Copy link
Member

xxchan commented Dec 24, 2024

❯ cargo clippy -p risingwave_pb
   Compiling risingwave_pb v2.3.0-alpha (/Users/xxchan/Projects/risingwave/src/prost)
warning: large size difference between variants
   --> src/prost/src/expr.rs:867:5
    |
867 | /     pub enum RexNode {
868 | |         #[prost(uint32, tag = "4")]
869 | |         InputRef(u32),
870 | |         #[prost(message, tag = "5")]
871 | |         Constant(super::super::data::Datum),
    | |         ----------------------------------- the second-largest variant contains at least 24 bytes
...   |
875 | |         Udf(super::UserDefinedFunction),
    | |         ------------------------------- the largest variant contains at least 248 bytes
876 | |         #[prost(message, tag = "8")]
877 | |         Now(NowRexNode),
878 | |     }
    | |_____^ the entire enum is at least 248 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
    = note: `#[warn(clippy::large_enum_variant)]` on by default
help: consider boxing the large fields to reduce the total size of the enum
    |
875 |         Udf(Box<super::UserDefinedFunction>),
    |             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
    --> src/prost/src/expr.rs:1539:5
     |
1539 | /     pub enum Type {
1540 | |         #[prost(enumeration = "GeneralType", tag = "1")]
1541 | |         General(i32),
     | |         ------------ the second-largest variant contains at least 4 bytes
1542 | |         /// Deprecated since we have a new `aggregate2` variant.
...    |
1546 | |         Aggregate2(super::AggType),
     | |         -------------------------- the largest variant contains at least 600 bytes
1547 | |     }
     | |_____^ the entire enum is at least 600 bytes
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
     |
1546 |         Aggregate2(Box<super::AggType>),
     |                    ~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
   --> src/prost/src/meta.rs:826:5
    |
826 | /     pub enum RelationInfo {
827 | |         #[prost(message, tag = "1")]
828 | |         Table(super::super::catalog::Table),
    | |         ----------------------------------- the largest variant contains at least 904 bytes
829 | |         #[prost(message, tag = "2")]
...   |
834 | |         Index(super::super::catalog::Index),
    | |         ----------------------------------- the second-largest variant contains at least 184 bytes
...   |
838 | |         Subscription(super::super::catalog::Subscription),
839 | |     }
    | |_____^ the entire enum is at least 0 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
828 |         Table(Box<super::super::catalog::Table>),
    |               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
   --> src/prost/src/meta.rs:916:5
    |
916 | /     pub enum Info {
917 | |         #[prost(message, tag = "4")]
918 | |         Database(super::super::catalog::Database),
919 | |         #[prost(message, tag = "5")]
...   |
922 | |         Function(super::super::catalog::Function),
    | |         ----------------------------------------- the second-largest variant contains at least 312 bytes
...   |
932 | |         Snapshot(super::MetaSnapshot),
    | |         ----------------------------- the largest variant contains at least 688 bytes
...   |
952 | |         Secret(super::super::catalog::Secret),
953 | |     }
    | |_____^ the entire enum is at least 688 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
932 |         Snapshot(Box<super::MetaSnapshot>),
    |                  ~~~~~~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
   --> src/prost/src/stream_plan.rs:290:5
    |
290 | /     pub enum StreamMessage {
291 | |         #[prost(message, tag = "1")]
292 | |         StreamChunk(super::super::data::StreamChunk),
293 | |         #[prost(message, tag = "2")]
294 | |         Barrier(super::Barrier),
    | |         ----------------------- the largest variant contains at least 320 bytes
295 | |         #[prost(message, tag = "3")]
296 | |         Watermark(super::Watermark),
    | |         --------------------------- the second-largest variant contains at least 104 bytes
297 | |     }
    | |_____^ the entire enum is at least 320 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
294 |         Barrier(Box<super::Barrier>),
    |                 ~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
   --> src/prost/src/stream_plan.rs:561:5
    |
561 | /     pub enum Inner {
562 | |         #[prost(message, tag = "1")]
563 | |         ValueState(ValueState),
    | |         ---------------------- the second-largest variant contains at least 0 bytes
564 | |         #[prost(message, tag = "3")]
565 | |         MaterializedInputState(MaterializedInputState),
    | |         ---------------------------------------------- the largest variant contains at least 976 bytes
566 | |     }
    | |_____^ the entire enum is at least 976 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
565 |         MaterializedInputState(Box<MaterializedInputState>),
    |                                ~~~~~~~~~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
    --> src/prost/src/stream_plan.rs:1273:5
     |
1273 | /     pub enum NodeBody {
1274 | |         #[prost(message, tag = "100")]
1275 | |         Source(super::SourceNode),
1276 | |         #[prost(message, tag = "101")]
...    |
1291 | |         HashJoin(super::HashJoinNode),
     | |         ----------------------------- the largest variant contains at least 4120 bytes
...    |
1319 | |         DynamicFilter(super::DynamicFilterNode),
     | |         --------------------------------------- the second-largest variant contains at least 2144 bytes
...    |
1367 | |         AsOfJoin(super::AsOfJoinNode),
1368 | |     }
     | |_____^ the entire enum is at least 0 bytes
     |
     = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
     |
1291 |         HashJoin(Box<super::HashJoinNode>),
     |                  ~~~~~~~~~~~~~~~~~~~~~~~~

warning: large size difference between variants
   --> src/prost/src/stream_service.rs:168:5
    |
168 | /     pub enum Request {
169 | |         #[prost(message, tag = "1")]
170 | |         Init(InitRequest),
171 | |         #[prost(message, tag = "2")]
172 | |         InjectBarrier(super::InjectBarrierRequest),
    | |         ------------------------------------------ the largest variant contains at least 496 bytes
173 | |         #[prost(message, tag = "3")]
174 | |         RemovePartialGraph(RemovePartialGraphRequest),
    | |         --------------------------------------------- the second-largest variant contains at least 32 bytes
...   |
178 | |         ResetDatabase(ResetDatabaseRequest),
179 | |     }
    | |_____^ the entire enum is at least 496 bytes
    |
    = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#large_enum_variant
help: consider boxing the large fields to reduce the total size of the enum
    |
172 |         InjectBarrier(Box<super::InjectBarrierRequest>),
    |                       ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@xxchan
Copy link
Member Author

xxchan commented Dec 24, 2024

We need either tokio-rs/prost#1211 or tokio-rs/prost#1209 to do it elegantly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant