Skip to content

Commit

Permalink
Add a few more latency metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
lxfind committed Sep 20, 2024
1 parent 060f9de commit 7334cde
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/gas_pool/gas_pool_core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,15 @@ impl GasPool {
gas_budget: u64,
duration: Duration,
) -> anyhow::Result<(SuiAddress, ReservationID, Vec<ObjectRef>)> {
let cur_time = std::time::Instant::now();
self.gas_usage_cap.check_usage().await?;
let sponsor = self.signer.get_address();
let (reservation_id, gas_coins) = self
.gas_pool_store
.reserve_gas_coins(gas_budget, duration.as_millis() as u64)
.await?;
let elapsed = cur_time.elapsed().as_millis();
self.metrics.reserve_gas_latency_ms.observe(elapsed as u64);
self.metrics
.reserved_gas_coin_count_per_request
.observe(gas_coins.len() as u64);
Expand Down Expand Up @@ -181,6 +184,7 @@ impl GasPool {
user_sig: GenericSignature,
) -> anyhow::Result<SuiTransactionBlockEffects> {
let sponsor = tx_data.gas_data().owner;
let cur_time = std::time::Instant::now();
let sponsor_sig = retry_with_max_attempts!(
async {
self.signer
Expand All @@ -190,7 +194,12 @@ impl GasPool {
},
3
)?;
let elapsed = cur_time.elapsed().as_millis();
self.metrics
.transaction_signing_latency_ms
.observe(elapsed as u64);
debug!(?reservation_id, "Transaction signed by sponsor");

let tx = Transaction::from_generic_sig_data(tx_data, vec![sponsor_sig, user_sig]);
let cur_time = std::time::Instant::now();
let effects = self.sui_client.execute_transaction(tx, 3).await?;
Expand Down
12 changes: 12 additions & 0 deletions src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ pub struct GasPoolCoreMetrics {
pub num_expired_gas_coins: IntCounterVec,
pub num_smashed_gas_coins: IntCounterVec,
pub reserved_gas_coin_count_per_request: Histogram,
pub reserve_gas_latency_ms: Histogram,
pub transaction_signing_latency_ms: Histogram,
pub transaction_execution_latency_ms: Histogram,
pub num_gas_pool_invariant_violations: IntCounter,
pub daily_gas_usage: IntGaugeVec,
Expand Down Expand Up @@ -128,6 +130,16 @@ impl GasPoolCoreMetrics {
registry,
)
.unwrap(),
reserve_gas_latency_ms: Histogram::new_in_registry(
"reserve_gas_latency",
"Latency of gas reservation, in milliseconds",
registry,
),
transaction_signing_latency_ms: Histogram::new_in_registry(
"transaction_signing_latency",
"Latency of transaction signing, in milliseconds",
registry,
),
transaction_execution_latency_ms: Histogram::new_in_registry(
"transaction_execution_latency",
"Latency of transaction execution, in milliseconds",
Expand Down

0 comments on commit 7334cde

Please sign in to comment.