Conversation
| if let Some(timestamp) = self.timestamp { | ||
| self.block_times.push(now.saturating_sub(timestamp)); | ||
| self.average_block_time = Some(self.block_times.average()); | ||
| match block.height.cmp(&self.best.height) { |
There was a problem hiding this comment.
I'm not a fan of this change if think the old code was easier to read.
which clippy lint is this?
There was a problem hiding this comment.
| ("1Mi", 1 * 1024 * 1024), | ||
| ("1GiB", 1 * 1024 * 1024 * 1024), | ||
| ("1Gi", 1 * 1024 * 1024 * 1024), | ||
| (" 1 Gi ", 1 * 1024 * 1024 * 1024), |
There was a problem hiding this comment.
these are just silly, so much more readable before :)
perhaps we could should add a clippy config for style lints like this one.
There was a problem hiding this comment.
I'd be up for a clippy config being added to telemetry so that we can keep more of what we like; I'm generally happy with these changes but there isn't much value in adding Default impls and a couple of other nits I have (but I htink nits are allowed since that's what clippy is all about!)
| impl<Id, Details> Default for AssignId<Id, Details> | ||
| where | ||
| Details: Eq + Hash, | ||
| Id: From<usize> + Copy, | ||
| usize: From<Id>, | ||
| { | ||
| fn default() -> Self { | ||
| Self::new() | ||
| } | ||
| } |
There was a problem hiding this comment.
I guess #[derive(Default)] didn't work? I'd prefer that if possible :)
There was a problem hiding this comment.
BiMap doesn't impl Default
|
I'm ok with most of these changes, but perhaps we should sit down, make an issue and write a proper clippy config as @niklasad1 suggests so that we can decide what we want to ignore/change in telemetry and then run over and this the warnings there. @niklasad1 are you up for doing that when you have some time? |
| local_id: ShardNodeId, | ||
| ip: std::net::IpAddr, | ||
| node: common::node_types::NodeDetails, | ||
| node: Box<common::node_types::NodeDetails>, |
There was a problem hiding this comment.
std::mem::size_of::<NodeDetails>() == 111
I think that is small enough to avoid to Box this one
There was a problem hiding this comment.
Yeah, but enum variant is around 369 bytes:
warning: large size difference between variants
--> telemetry_core/src/aggregator/inner_loop.rs:48:1
|
48 | / pub enum FromShardWebsocket {
49 | | /// When the socket is opened, it'll send this first
50 | | /// so that we have a way to communicate back to it.
51 | | Initialize {
... |
55 | / | Add {
56 | | | local_id: ShardNodeId,
57 | | | ip: std::net::IpAddr,
58 | | | node: common::node_types::NodeDetails,
59 | | | genesis_hash: common::node_types::BlockHash,
60 | | | },
| |_|_____- the largest variant contains at least 369 bytes
61 | | /// Update/pass through details about a node.
62 | / | Update {
63 | | | local_id: ShardNodeId,
64 | | | payload: Box<node_message::Payload>,
65 | | | },
| |_|_____- the second-largest variant contains at least 16 bytes
... |
69 | | Disconnected,
70 | | }
| |_^ the entire enum is at least 376 bytes
|
= note: `#[warn(clippy::large_enum_variant)]` on by default
= 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
|
58 | node: Box<common::node_types::NodeDetails>,
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| Update { | ||
| local_id: ShardNodeId, | ||
| payload: node_message::Payload, | ||
| payload: Box<node_message::Payload>, |
There was a problem hiding this comment.
std::mem::size_of::<Payload>() == 344, I'm still in favor to avoid to box this but not sure where to cut the threshold without benching it ^^.
Clippy seems to use 200 as default, https://rust-lang.github.io/rust-clippy/master/#large_enum_variant
Sure, it seems like I'm the grumpy one against the default clippy warnings so sure :) |
|
I'd suggest just starting with this PR if it's useful, adding some clippy rules, adding the CI check too (since this PR doesn't have it) and making a new PR. Then we can close this one since it's conflicting at the mo anyway. But whatever is easiest! |
No description provided.