Repository navigation
apollo_network_benchmark: add MessageIndexTracker struct #11556
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| // TODO(AndrewL): remove this once the struct is used | ||
| #![allow(dead_code)] | ||
|
|
||
| #[derive(Default, Clone, Copy)] | ||
| pub struct MessageIndexTracker { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Module name mismatches struct name semanticallyLow Severity The module is named Additional Locations (1) |
||
| seen_messages_count: u64, | ||
| max_message_index: Option<u64>, | ||
| min_message_index: Option<u64>, | ||
| } | ||
|
|
||
| impl MessageIndexTracker { | ||
| pub fn seen_message(&mut self, message_index: u64) { | ||
| self.seen_messages_count += 1; | ||
| if self.max_message_index.is_none() || self.max_message_index.unwrap() < message_index { | ||
| self.max_message_index = Some(message_index); | ||
| } | ||
| if self.min_message_index.is_none() || self.min_message_index.unwrap() > message_index { | ||
| self.min_message_index = Some(message_index); | ||
| } | ||
| } | ||
|
|
||
| pub fn pending_messages_count(&self) -> u64 { | ||
| if self.seen_messages_count == 0 { | ||
| return 0; | ||
| } | ||
|
|
||
| let min_message_index = self.min_message_index.unwrap(); | ||
| let max_message_index = self.max_message_index.unwrap(); | ||
| max_message_index - min_message_index + 1 - self.seen_messages_count | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Duplicate indices break pending countLow Severity
Additional Locations (1) |
||
| } | ||
| } | ||


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.
New tracker code is currently unused
Low Severity
message_index_detectoris added to the binary, butMessageIndexTracker,seen_message(), andpending_messages_count()are not referenced anywhere else. The file also suppresses this with#![allow(dead_code)], which leaves dead code in production and increases maintenance risk.Additional Locations (1)
crates/apollo_network_benchmark/src/bin/broadcast_network_stress_test_node/message_index_detector.rs#L1-L31