-
Notifications
You must be signed in to change notification settings - Fork 304
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
Report ConsumeWorkerMetrics at slot transitions #3212
Changes from 1 commit
716ca7f
82b7ff1
ad06977
f58a61f
3a20d04
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 |
---|---|---|
|
@@ -8,7 +8,7 @@ use { | |
solana_measure::measure_us, | ||
solana_poh::leader_bank_notifier::LeaderBankNotifier, | ||
solana_runtime::bank::Bank, | ||
solana_sdk::timing::AtomicInterval, | ||
solana_sdk::clock::Slot, | ||
solana_svm::transaction_error_metrics::TransactionErrorMetrics, | ||
std::{ | ||
sync::{ | ||
|
@@ -170,21 +170,31 @@ fn try_drain_iter<T>(work: T, receiver: &Receiver<T>) -> impl Iterator<Item = T> | |
/// done. | ||
pub(crate) struct ConsumeWorkerMetrics { | ||
id: String, | ||
interval: AtomicInterval, | ||
has_data: AtomicBool, | ||
slot: AtomicU64, | ||
|
||
count_metrics: ConsumeWorkerCountMetrics, | ||
error_metrics: ConsumeWorkerTransactionErrorMetrics, | ||
timing_metrics: ConsumeWorkerTimingMetrics, | ||
} | ||
|
||
impl ConsumeWorkerMetrics { | ||
/// Report and reset metrics iff the interval has elapsed and the worker did some work. | ||
pub fn maybe_report_and_reset(&self) { | ||
const REPORT_INTERVAL_MS: u64 = 1000; | ||
if self.interval.should_update(REPORT_INTERVAL_MS) | ||
&& self.has_data.swap(false, Ordering::Relaxed) | ||
{ | ||
/// Report and reset metrics when the worker did some work and: | ||
/// a) (when a leader) Previous slot is not the same as current. | ||
/// b) (when not a leader) report the metrics accumulated so far. | ||
pub fn maybe_report_and_reset(&self, slot: Option<Slot>) { | ||
if let Some(slot) = slot { | ||
let prev_slot_id: u64 = self.slot.load(Ordering::Relaxed); | ||
if slot != prev_slot_id { | ||
if !self.has_data.swap(false, Ordering::Relaxed) { | ||
return; | ||
} | ||
self.count_metrics.report_and_reset(&self.id); | ||
self.timing_metrics.report_and_reset(&self.id); | ||
self.error_metrics.report_and_reset(&self.id); | ||
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. we need to report the slot on these metrics too. otherwise we can't directly associate them 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. probably best to add |
||
self.slot.swap(slot, Ordering::Relaxed); | ||
} | ||
} else { | ||
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. this will spam, we need to check if there was or was not a previous slot stored in the metrics 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. every time the scheduler loop runs it may call into this function. this function needs to check if the slot is different than what was previously there |
||
self.count_metrics.report_and_reset(&self.id); | ||
self.timing_metrics.report_and_reset(&self.id); | ||
self.error_metrics.report_and_reset(&self.id); | ||
|
@@ -194,8 +204,8 @@ impl ConsumeWorkerMetrics { | |
fn new(id: u32) -> Self { | ||
Self { | ||
id: id.to_string(), | ||
interval: AtomicInterval::default(), | ||
has_data: AtomicBool::new(false), | ||
slot: AtomicU64::new(0), | ||
count_metrics: ConsumeWorkerCountMetrics::default(), | ||
error_metrics: ConsumeWorkerTransactionErrorMetrics::default(), | ||
timing_metrics: ConsumeWorkerTimingMetrics::default(), | ||
|
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 function may be called more than once per leader slot.
we need to check that the slot is different than the cached slot before resetting
has_data