better error messages + cleaner printing of file stats + tracing

instrumentation in `execute_interaction`
This commit is contained in:
pedrocarlo 2025-06-08 13:50:06 -03:00
parent e19fa9f951
commit 83d72db901
5 changed files with 52 additions and 46 deletions

View file

@ -1,6 +1,7 @@
use std::sync::{Arc, Mutex};
use limbo_core::{LimboError, Result};
use tracing::instrument;
use crate::generation::{
pick_index,
@ -173,17 +174,15 @@ pub(crate) enum ExecutionContinuation {
NextProperty,
}
#[instrument(skip(env, interaction, stack), fields(interaction = %interaction))]
pub(crate) fn execute_interaction(
env: &mut SimulatorEnv,
connection_index: usize,
interaction: &Interaction,
stack: &mut Vec<ResultSet>,
) -> Result<ExecutionContinuation> {
tracing::info!(
"execute_interaction(connection_index={}, interaction={})",
connection_index,
interaction
);
// Leave this empty info! here to print the span of the execution
tracing::info!("");
match interaction {
Interaction::Query(_) => {
let conn = match &mut env.connections[connection_index] {
@ -192,7 +191,6 @@ pub(crate) fn execute_interaction(
SimConnection::Disconnected => unreachable!(),
};
tracing::debug!("{}", interaction);
let results = interaction.execute_query(conn, &env.io);
tracing::debug!("{:?}", results);
stack.push(results);

View file

@ -31,30 +31,34 @@ impl SimulatorFile {
self.fault.replace(fault);
}
pub(crate) fn print_stats(&self) {
tracing::info!("op calls faults");
tracing::info!("--------- -------- --------");
tracing::info!(
"pread {:8} {:8}",
*self.nr_pread_calls.borrow(),
*self.nr_pread_faults.borrow()
);
tracing::info!(
"pwrite {:8} {:8}",
*self.nr_pwrite_calls.borrow(),
*self.nr_pwrite_faults.borrow()
);
tracing::info!(
"sync {:8} {:8}",
*self.nr_sync_calls.borrow(),
0 // No fault counter for sync
);
tracing::info!("--------- -------- --------");
pub(crate) fn stats_table(&self) -> String {
let sum_calls = *self.nr_pread_calls.borrow()
+ *self.nr_pwrite_calls.borrow()
+ *self.nr_sync_calls.borrow();
let sum_faults = *self.nr_pread_faults.borrow() + *self.nr_pwrite_faults.borrow();
tracing::info!("total {:8} {:8}", sum_calls, sum_faults);
let stats_table = [
"op calls faults".to_string(),
"--------- -------- --------".to_string(),
format!(
"pread {:8} {:8}",
*self.nr_pread_calls.borrow(),
*self.nr_pread_faults.borrow()
),
format!(
"pwrite {:8} {:8}",
*self.nr_pwrite_calls.borrow(),
*self.nr_pwrite_faults.borrow()
),
format!(
"sync {:8} {:8}",
*self.nr_sync_calls.borrow(),
0 // No fault counter for sync
),
"--------- -------- --------".to_string(),
format!("total {:8} {:8}", sum_calls, sum_faults),
];
let table = stats_table.join("\n");
table
}
}

View file

@ -45,9 +45,7 @@ impl SimulatorIO {
pub(crate) fn print_stats(&self) {
tracing::info!("run_once faults: {}", self.nr_run_once_faults.borrow());
for file in self.files.borrow().iter() {
tracing::info!("");
tracing::info!("===========================");
file.print_stats();
tracing::info!("\n===========================\n{}", file.stats_table());
}
}
}