Priority fee related statistics

This commit is contained in:
godmodegalactus 2024-03-18 21:57:32 +01:00
parent 92cc790fef
commit 596957f65e
No known key found for this signature in database
GPG Key ID: 22DA4A30887FDA3C
3 changed files with 35 additions and 6 deletions

View File

@ -69,14 +69,14 @@ pub struct QuicConnectionParameters {
impl Default for QuicConnectionParameters { impl Default for QuicConnectionParameters {
fn default() -> Self { fn default() -> Self {
Self { Self {
connection_timeout: Duration::from_millis(5000), connection_timeout: Duration::from_millis(10000),
unistream_timeout: Duration::from_millis(5000), unistream_timeout: Duration::from_millis(10000),
write_timeout: Duration::from_millis(5000), write_timeout: Duration::from_millis(10000),
finalize_timeout: Duration::from_millis(5000), finalize_timeout: Duration::from_millis(10000),
connection_retry_count: 20, connection_retry_count: 20,
max_number_of_connections: 8, max_number_of_connections: 8,
number_of_transactions_per_unistream: 1, number_of_transactions_per_unistream: 1,
percentage_of_connection_limit_to_create_new: 50, percentage_of_connection_limit_to_create_new: 75,
} }
} }
} }

View File

@ -1,6 +1,8 @@
use dashmap::DashMap; use dashmap::DashMap;
use log::{error, trace}; use log::{error, trace};
use prometheus::{core::GenericGauge, opts, register_int_gauge}; use prometheus::{
core::GenericGauge, histogram_opts, opts, register_histogram, register_int_gauge, Histogram,
};
use quinn::Endpoint; use quinn::Endpoint;
use solana_lite_rpc_core::{ use solana_lite_rpc_core::{
stores::data_cache::DataCache, stores::data_cache::DataCache,
@ -39,6 +41,15 @@ lazy_static::lazy_static! {
register_int_gauge!(opts!("literpc_connections_to_keep", "Number of connections to keep asked by tpu service")).unwrap(); register_int_gauge!(opts!("literpc_connections_to_keep", "Number of connections to keep asked by tpu service")).unwrap();
static ref NB_QUIC_TASKS: GenericGauge<prometheus::core::AtomicI64> = static ref NB_QUIC_TASKS: GenericGauge<prometheus::core::AtomicI64> =
register_int_gauge!(opts!("literpc_quic_tasks", "Number of connections to keep asked by tpu service")).unwrap(); register_int_gauge!(opts!("literpc_quic_tasks", "Number of connections to keep asked by tpu service")).unwrap();
static ref TT_SENT_TIMER: Histogram = register_histogram!(histogram_opts!(
"literpc_txs_send_timer",
"Time to send transaction batch",
))
.unwrap();
static ref TRANSACTIONS_IN_HEAP: GenericGauge<prometheus::core::AtomicI64> =
register_int_gauge!(opts!("literpc_transactions_in_priority_heap", "Number of transactions in priority heap")).unwrap();
} }
#[derive(Clone)] #[derive(Clone)]
@ -101,6 +112,8 @@ impl ActiveConnection {
} }
priorization_heap.insert(transaction_sent_info).await; priorization_heap.insert(transaction_sent_info).await;
TRANSACTIONS_IN_HEAP.inc();
fill_notify.notify_one(); fill_notify.notify_one();
// give little more priority to read the transaction sender with this wait // give little more priority to read the transaction sender with this wait
let last_blockheight = let last_blockheight =
@ -166,6 +179,7 @@ impl ActiveConnection {
// wait to get notification from fill event // wait to get notification from fill event
break; break;
}; };
TRANSACTIONS_IN_HEAP.dec();
// check if transaction is already confirmed // check if transaction is already confirmed
if self.data_cache.txs.is_transaction_confirmed(&tx.signature) { if self.data_cache.txs.is_transaction_confirmed(&tx.signature) {
@ -186,8 +200,12 @@ impl ActiveConnection {
tokio::spawn(async move { tokio::spawn(async move {
// permit will be used to send all the transaction and then destroyed // permit will be used to send all the transaction and then destroyed
let _permit = permit; let _permit = permit;
let timer = TT_SENT_TIMER.start_timer();
NB_QUIC_TASKS.inc(); NB_QUIC_TASKS.inc();
connection.send_transaction(tx.transaction).await; connection.send_transaction(tx.transaction).await;
timer.observe_duration();
NB_QUIC_TASKS.dec(); NB_QUIC_TASKS.dec();
}); });
} }

View File

@ -9,6 +9,7 @@ use crate::{
tx_sender::TxSender, tx_sender::TxSender,
}; };
use anyhow::bail; use anyhow::bail;
use prometheus::{histogram_opts, register_histogram, Histogram};
use solana_lite_rpc_core::{ use solana_lite_rpc_core::{
solana_utils::SerializableTransaction, structures::transaction_sent_info::SentTransactionInfo, solana_utils::SerializableTransaction, structures::transaction_sent_info::SentTransactionInfo,
types::SlotStream, types::SlotStream,
@ -28,6 +29,14 @@ use tokio::{
time::Instant, time::Instant,
}; };
lazy_static::lazy_static! {
static ref PRIORITY_FEES_HISTOGRAM: Histogram = register_histogram!(histogram_opts!(
"literpc_txs_priority_fee",
"Priority fees of transactions sent by lite-rpc",
))
.unwrap();
}
#[derive(Clone)] #[derive(Clone)]
pub struct TransactionServiceBuilder { pub struct TransactionServiceBuilder {
tx_sender: TxSender, tx_sender: TxSender,
@ -157,6 +166,8 @@ impl TransactionService {
prioritization_fee prioritization_fee
}; };
PRIORITY_FEES_HISTOGRAM.observe(prioritization_fee as f64);
let max_replay = max_retries.map_or(self.max_retries, |x| x as usize); let max_replay = max_retries.map_or(self.max_retries, |x| x as usize);
let transaction_info = SentTransactionInfo { let transaction_info = SentTransactionInfo {
signature: signature.to_string(), signature: signature.to_string(),