Skip to content

Commit

Permalink
log timings to CSV
Browse files Browse the repository at this point in the history
  • Loading branch information
grooviegermanikus committed Nov 22, 2023
1 parent fc49127 commit e068c97
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions lite-rpc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ tokio = { version = "1.28.2", features = ["full", "fs"]}
tokio-util = "0.7"
tokio-postgres = { version = "0.7.8", features = ["with-chrono-0_4"] }
chrono = { workspace = true }
csv = "1.3.0"

solana-lite-rpc-core = { workspace = true }
solana-lite-rpc-services = { workspace = true }
Expand Down
18 changes: 18 additions & 0 deletions lite-rpc/tests/storage_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ use std::process;
use std::str::FromStr;
use std::sync::Arc;
use std::time::{Duration, Instant};
use csv::WriterBuilder;
use futures::channel::oneshot::Cancellation;
use serde::__private::ser::CannotSerializeVariant;
use tokio::join;
use tokio::sync::broadcast::error::RecvError;
use tokio::task::JoinHandle;
Expand Down Expand Up @@ -121,11 +123,22 @@ fn storage_prepare_epoch_schema(
(join_handle, building_epoch_schema)
}

#[derive(serde::Serialize)]
struct CsvRow {
slot: Slot,
tx_count: u32,
write_time_ms: u32,
}

// note: the consumer lags far behind the ingress of blocks and transactions
fn storage_listen(
block_notifier: BlockStream,
block_storage: Arc<PostgresBlockStore>,
) -> JoinHandle<()> {

let mut csv_writer = WriterBuilder::new().from_path(format!("block_tx_ingress-postgres.csv")).unwrap();


tokio::spawn(async move {
let mut block_notifier = block_notifier;
// this is the critical write loop
Expand Down Expand Up @@ -161,6 +174,11 @@ fn storage_listen(
if elapsed > Duration::from_millis(150) {
warn!("(soft_realtime) Write operation was slow!");
}
csv_writer.serialize(CsvRow {
slot: block.slot,
tx_count: block.transactions.len() as u32,
write_time_ms: elapsed.as_millis() as u32,
}).unwrap();
} // -- Ok
Err(RecvError::Lagged(missed_blocks)) => {
warn!(
Expand Down

0 comments on commit e068c97

Please sign in to comment.