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

histo for cost tracker metrics #562

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions cost-model/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ license = { workspace = true }
edition = { workspace = true }

[dependencies]
histogram = { workspace = true }
lazy_static = { workspace = true }
log = { workspace = true }
solana-address-lookup-table-program = { workspace = true }
Expand Down
77 changes: 77 additions & 0 deletions cost-model/src/cost_tracker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//!
use {
crate::{block_cost_limits::*, transaction_cost::TransactionCost},
log::error,
solana_metrics::datapoint_info,
solana_sdk::{
clock::Slot, pubkey::Pubkey, saturating_add_assign, transaction::TransactionError,
Expand Down Expand Up @@ -65,6 +66,8 @@ pub struct CostTracker {
/// the tracker, but are still waiting for an update with actual usage or
/// removal if the transaction does not end up getting committed.
in_flight_transaction_count: usize,
committed_transactions_actual_cost: histogram::Histogram,
committed_transactions_estimated_cost: histogram::Histogram,
}

impl Default for CostTracker {
Expand All @@ -88,6 +91,8 @@ impl Default for CostTracker {
secp256k1_instruction_signature_count: 0,
ed25519_instruction_signature_count: 0,
in_flight_transaction_count: 0,
committed_transactions_actual_cost: histogram::Histogram::default(),
committed_transactions_estimated_cost: histogram::Histogram::default(),
}
}
}
Expand Down Expand Up @@ -134,6 +139,24 @@ impl CostTracker {
actual_execution_units: u64,
) {
let estimated_execution_units = estimated_tx_cost.programs_execution_cost();
if let Err(e) = self
.committed_transactions_actual_cost
.increment(actual_execution_units)
{
error!(
"Failed to increment committed_transactions_actual_cost: {:?}",
e
);
}
if let Err(e) = self
.committed_transactions_estimated_cost
.increment(actual_execution_units)
{
error!(
"Failed to increment committed_transactions_estimated_cost: {:?}",
e
);
}
match actual_execution_units.cmp(&estimated_execution_units) {
Ordering::Equal => (),
Ordering::Greater => {
Expand Down Expand Up @@ -201,6 +224,60 @@ impl CostTracker {
self.in_flight_transaction_count,
i64
),
(
"committed_transactions_actual_cost_min",
self.committed_transactions_actual_cost
.minimum()
.unwrap_or(0),
i64
),
(
"committed_transactions_actual_cost_mean",
self.committed_transactions_actual_cost.mean().unwrap_or(0),
i64
),
(
"committed_transactions_actual_cost_90p",
self.committed_transactions_actual_cost
.percentile(90.0)
.unwrap_or(0),
i64
),
(
"committed_transactions_actual_cost_max",
self.committed_transactions_actual_cost
.maximum()
.unwrap_or(0),
i64
),
(
"committed_transactions_estimated_cost_min",
self.committed_transactions_estimated_cost
.minimum()
.unwrap_or(0),
i64
),
(
"committed_transactions_estimated_cost_mean",
self.committed_transactions_estimated_cost
.mean()
.unwrap_or(0),
i64
),
(
"committed_transactions_estimated_cost_90p",
self.committed_transactions_estimated_cost
.percentile(90.0)
.unwrap_or(0),
i64
),
(
"committed_transactions_estimated_cost_max",
self.committed_transactions_estimated_cost
.maximum()
.unwrap_or(0),
i64
),
);
}

Expand Down
1 change: 1 addition & 0 deletions programs/sbf/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading