Skip to content
Draft
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 crates/tracedecay-rusqlite-runtime/src/connection/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ impl OpenedDatabaseFile {
Ok(())
}

#[hotpath::measure(label = "rusqlite.connection.verify_identity")]
pub(crate) fn verify_connection(
&self,
_connection: &Connection,
Expand Down
9 changes: 9 additions & 0 deletions crates/tracedecay-rusqlite-runtime/src/exact_sql/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ impl ExactSqlHandle {
}

/// Checkpoints and truncates the WAL on the serialized writer connection.
#[hotpath::measure(label = "rusqlite.exact_sql.checkpoint_wal_truncate")]
pub fn checkpoint_wal_truncate(&self) -> Result<ExactSqlRows, ExactSqlError> {
let (reply, response) = mpsc::sync_channel(1);
self.writer
Expand Down Expand Up @@ -365,6 +366,7 @@ impl ExactSqlHandle {
/// anything reports a typed no-op instead of [`ExactSqlError::WriterUnavailable`];
/// a reader release that *errored* is never a no-op — it propagates so
/// the maintenance caller's degraded log fires.
#[hotpath::measure(label = "rusqlite.exact_sql.release_memory")]
pub fn release_connection_memory(&self) -> Result<MemoryReleaseOutcome, ExactSqlError> {
let readers = (self.release_reader_memory)()?;
let writer = if self.writer.is_some() {
Expand All @@ -381,6 +383,7 @@ impl ExactSqlHandle {
}

/// Enables incremental auto-vacuum through its fixed maintenance rebuild.
#[hotpath::measure(label = "rusqlite.exact_sql.repair_auto_vacuum")]
pub fn repair_incremental_auto_vacuum(&self) -> Result<(), ExactSqlError> {
let (reply, response) = mpsc::sync_channel(1);
self.writer
Expand Down Expand Up @@ -628,6 +631,7 @@ impl ExactSqlTransaction {
}
}

#[hotpath::measure(label = "rusqlite.exact_sql.txn_commit")]
pub fn commit(mut self) -> Result<ExactSqlCommitReceipt, ExactSqlError> {
let sender = self
.commands
Expand All @@ -642,6 +646,7 @@ impl ExactSqlTransaction {
.map_err(|_| transaction_terminal_error(&self.expired))?
}

#[hotpath::measure(label = "rusqlite.exact_sql.txn_rollback")]
pub fn rollback(mut self) -> Result<ExactSqlRollbackReceipt, ExactSqlError> {
let sender = self
.commands
Expand All @@ -660,6 +665,7 @@ impl ExactSqlTransaction {
self.dispatch_with_policy(request, ExecutionPolicy::Bounded)
}

#[hotpath::measure(label = "rusqlite.exact_sql.txn_dispatch")]
fn dispatch_with_policy(
&self,
request: SqlRequest,
Expand Down Expand Up @@ -823,6 +829,7 @@ fn execute_statement(
})
}

#[hotpath::measure(label = "rusqlite.exact_sql.attach_db")]
fn attach_database(
connection: &Connection,
attachment: &ExactSqlAttachment,
Expand Down Expand Up @@ -851,6 +858,7 @@ fn attach_database(
)
}

#[hotpath::measure(label = "rusqlite.exact_sql.detach_db")]
fn detach_database(
connection: &Connection,
database_name: &str,
Expand Down Expand Up @@ -878,6 +886,7 @@ fn detach_database(
)
}

#[hotpath::measure(label = "rusqlite.exact_sql.execute_batch")]
fn execute_batch(connection: &Connection, sql: &str) -> Result<ExactSqlBatchResult, ExactSqlError> {
let before = connection.total_changes();
connection
Expand Down
8 changes: 8 additions & 0 deletions crates/tracedecay-rusqlite-runtime/src/reader/pool/lease.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
self.checkout.retire = true;
}

#[hotpath::measure(label = "rusqlite.reader_lease.begin_snapshot")]
pub fn begin_snapshot(&mut self) -> Result<SnapshotLease<'_, E>, ReaderWorkerError> {
if self.snapshot_active {
return Err(ReaderWorkerError::SnapshotAlreadyActive);
Expand All @@ -134,6 +135,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
Ok(SnapshotLease { lease: self })
}

#[hotpath::measure(label = "rusqlite.reader_lease.execute")]
pub(crate) fn execute_active_raw(
&mut self,
request: RuntimeReadRequestV1,
Expand Down Expand Up @@ -161,6 +163,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
.map_err(map_worker_error)
}

#[hotpath::measure(label = "rusqlite.reader_lease.exact_sql_query")]
pub(super) fn execute_exact_sql_query(
&mut self,
statement: ExactSqlStatement,
Expand All @@ -182,6 +185,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
.execute_exact_sql_query(statement)
}

#[hotpath::measure(label = "rusqlite.reader_lease.begin_exact_sql_snapshot")]
pub(super) fn begin_exact_sql_snapshot(&mut self) -> Result<(), ExactSqlError> {
if self.snapshot_active {
return Err(ExactSqlError::ReaderUnavailable(
Expand All @@ -197,6 +201,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
self.checkout.worker.client.pin_exact_sql()
}

#[hotpath::measure(label = "rusqlite.reader_lease.exact_sql_snapshot_query")]
pub(super) fn execute_active_exact_sql_query(
&mut self,
statement: ExactSqlStatement,
Expand All @@ -212,6 +217,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
.execute_exact_sql_query(statement)
}

#[hotpath::measure(label = "rusqlite.reader_lease.store_size")]
pub(super) fn read_store_size(
&mut self,
reply_bound: std::time::Duration,
Expand All @@ -234,6 +240,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
.map_err(map_worker_error)
}

#[hotpath::measure(label = "rusqlite.reader_lease.table_sizes")]
pub(super) fn read_table_sizes(
&mut self,
reply_bound: std::time::Duration,
Expand Down Expand Up @@ -274,6 +281,7 @@ impl<E: ReaderQueryExecutor> ReaderLease<E> {
.map_err(|error| ReaderAcquireError::Worker(ReaderWorkerError::Storage(error)))
}

#[hotpath::measure(label = "rusqlite.reader_lease.finish_snapshot")]
fn finish_snapshot(&mut self) {
if !self.snapshot_active {
return;
Expand Down
3 changes: 3 additions & 0 deletions crates/tracedecay-rusqlite-runtime/src/reader/pool/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,7 @@ impl<E: ReaderQueryExecutor> ReaderPool<E> {
/// Each worker connection keeps its own SQLite cache. Dispatching
/// `PRAGMA shrink_memory` through the writer actor would shrink the
/// wrong connection (or fail when no writer is attached).
#[hotpath::measure(label = "rusqlite.reader_pool.release_memory")]
pub(crate) fn release_connection_memory(&self) -> Result<MemoryReleaseOutcome, ExactSqlError> {
let (lifecycle, clients) = {
let state = self
Expand Down Expand Up @@ -906,6 +907,7 @@ impl<E: ReaderQueryExecutor> ReaderPool<E> {

/// Opportunistically retire burst workers. This method performs no sleep;
/// tests and maintenance callers can supply a deterministic monotonic time.
#[hotpath::measure(label = "rusqlite.reader_pool.retire_idle")]
pub fn retire_idle_at(&self, now: Instant) -> usize {
let mut retired = Vec::new();
{
Expand Down Expand Up @@ -944,6 +946,7 @@ impl<E: ReaderQueryExecutor> ReaderPool<E> {
retired.len()
}

#[hotpath::measure(label = "rusqlite.reader_pool.add_worker")]
fn add_idle_worker(&self, lane: ReaderLane) -> Result<(), ReaderStartError> {
let spawned = worker::spawn(
self.inner.locator.clone(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,7 @@ impl RemoteRecoverySqliteAuthorityV1 {

/// Publishes the authority-store value used by every later recovery CAS.
/// A lower epoch, or a different writer at the same epoch, is rejected.
#[hotpath::measure(label = "rusqlite.recovery.publish_authority")]
pub fn publish_authority(
&self,
authority: &CurrentRemoteAuthorityV1,
Expand Down Expand Up @@ -191,6 +192,7 @@ impl RemoteRecoverySqliteAuthorityV1 {
/// becomes available. The original admitted request and caller binding are
/// journaled before the write gate is visible, so recovery never depends
/// on an API caller retrying.
#[hotpath::measure(label = "rusqlite.recovery.reconcile_promotions")]
pub fn reconcile_interrupted_promotions(
&self,
project_id: &tracedecay_domain::ProjectId,
Expand Down Expand Up @@ -224,6 +226,7 @@ impl RemoteRecoverySqliteAuthorityV1 {
Ok(reconciled)
}

#[hotpath::measure(label = "rusqlite.recovery.seed_authority")]
fn ensure_authority_seeded(
&self,
expected: &RecoveryAuthorityExpectationV1,
Expand Down Expand Up @@ -256,6 +259,7 @@ impl RemoteRecoverySqliteAuthorityV1 {
.map_err(map_store_error)
}

#[hotpath::measure(label = "rusqlite.recovery.promotion_pending")]
fn promotion_is_pending(
&self,
operation_id: &str,
Expand All @@ -278,6 +282,7 @@ impl RemoteRecoverySqliteAuthorityV1 {
}

#[allow(clippy::too_many_arguments)]
#[hotpath::measure(label = "rusqlite.recovery.execute_operation")]
fn execute_operation<Request, Output>(
&self,
kind: &'static str,
Expand Down Expand Up @@ -404,6 +409,7 @@ impl RemoteRecoveryControlPortV1 for RecoveryReconciliationControlV1 {
}

impl RemoteSqliteStorageV1 {
#[hotpath::measure(label = "rusqlite.recovery.load_writer")]
pub fn recovery_writer(
&self,
expected: &RecoveryAuthorityExpectationV1,
Expand All @@ -426,6 +432,7 @@ impl RemoteSqliteStorageV1 {
Ok(writer)
}

#[hotpath::measure(label = "rusqlite.recovery.load_writer_lineage")]
pub fn recovery_writer_for_lineage(
&self,
expected: &RecoveryAuthorityExpectationV1,
Expand Down Expand Up @@ -517,6 +524,7 @@ impl RemoteRecoveryOperationPortV1 for RemoteRecoverySqliteAuthorityV1 {
)
}

#[hotpath::measure(label = "rusqlite.recovery.promote")]
fn promote(
&self,
request: &RemoteProtocolRequestV1<PromotionConfirmationV1>,
Expand Down Expand Up @@ -652,6 +660,7 @@ impl RemoteRecoveryOperationPortV1 for RemoteRecoverySqliteAuthorityV1 {
}
}

#[hotpath::measure(label = "rusqlite.recovery.authority_state")]
fn available_authority_state(
handle: &ExactSqlHandle,
expected: &RecoveryAuthorityExpectationV1,
Expand Down Expand Up @@ -815,6 +824,7 @@ fn validate_sink_inventory(sink_ids: &[String]) -> Result<(), RemoteRecoveryOper
Ok(())
}

#[hotpath::measure(label = "rusqlite.recovery.persist_sink_receipts")]
fn persist_sink_receipts(
handle: &ExactSqlHandle,
operation_id: &str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ const ACTIVATION_NOT_RECORDED: &str = "not_recorded_by_configuration_store_v1";
pub struct ConfigurationExecutor;

impl ConfigurationExecutor {
#[hotpath::measure(label = "rusqlite.configuration.write")]
pub fn execute_write(
&mut self,
savepoint: &Savepoint<'_>,
Expand Down Expand Up @@ -78,6 +79,7 @@ impl ConfigurationExecutor {
Ok(())
}

#[hotpath::measure(label = "rusqlite.configuration.read")]
pub fn execute_read(
&mut self,
snapshot: &Transaction<'_>,
Expand Down Expand Up @@ -138,6 +140,7 @@ fn current_revision_id(connection: &rusqlite::Connection) -> rusqlite::Result<Op
}
}

#[hotpath::measure(label = "rusqlite.configuration.insert_revision")]
fn insert_revision(
savepoint: &Savepoint<'_>,
revision: &ConfigurationRevisionRecordV1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const CLEARED: &str = DIAGNOSTIC_STATE_CLEARED;
pub struct DiagnosticExecutor;

impl DiagnosticExecutor {
#[hotpath::measure(label = "rusqlite.diagnostics.write")]
pub fn execute_write(
&mut self,
savepoint: &Savepoint<'_>,
Expand Down Expand Up @@ -106,6 +107,7 @@ impl DiagnosticExecutor {
/// lanes and must stay so: clearing marks records a newer clean generation
/// replaced wholesale, while supersession preserves a walkable chain from
/// a prior finding to its logical successor.
#[hotpath::measure(label = "rusqlite.diagnostics.supersede")]
pub fn execute_supersession(
&mut self,
savepoint: &Savepoint<'_>,
Expand All @@ -129,6 +131,7 @@ impl DiagnosticExecutor {
Ok(transitioned as u64)
}

#[hotpath::measure(label = "rusqlite.diagnostics.read")]
pub fn execute_read(
&mut self,
snapshot: &Transaction<'_>,
Expand Down Expand Up @@ -197,6 +200,7 @@ impl DiagnosticExecutor {
/// The walk stops at a current, cleared, or missing successor. An anchor
/// already visited also stops the walk, so a cyclic `state_generation` graph
/// cannot spin here.
#[hotpath::measure(label = "rusqlite.diagnostics.chain_walk")]
fn read_supersession_chain(
connection: &rusqlite::Connection,
anchor: &RetrievalAnchorId,
Expand Down Expand Up @@ -266,6 +270,7 @@ fn read_logical_successor(
Ok(records.pop())
}

#[hotpath::measure(label = "rusqlite.diagnostics.insert_record")]
fn insert_record(
savepoint: &Savepoint<'_>,
record: &GenerationDiagnosticV1,
Expand Down
7 changes: 7 additions & 0 deletions crates/tracedecay-rusqlite-runtime/src/repository/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub struct ProjectExecutor {
}

impl ProjectExecutor {
#[hotpath::measure(label = "rusqlite.project.fact_write")]
pub fn execute_fact_write(
&mut self,
savepoint: &Savepoint<'_>,
Expand All @@ -34,6 +35,7 @@ impl ProjectExecutor {
self.fact.execute_write(savepoint, batch)
}

#[hotpath::measure(label = "rusqlite.project.observation_write")]
pub fn execute_observation_write(
&mut self,
savepoint: &Savepoint<'_>,
Expand All @@ -54,6 +56,7 @@ impl ProjectExecutor {
Ok(())
}

#[hotpath::measure(label = "rusqlite.project.observation_batch")]
pub fn execute_observation_batch(
&mut self,
savepoint: &Savepoint<'_>,
Expand All @@ -65,6 +68,7 @@ impl ProjectExecutor {
Ok(())
}

#[hotpath::measure(label = "rusqlite.project.remote_observation_replay")]
pub fn execute_remote_observation_replay(
&mut self,
savepoint: &Savepoint<'_>,
Expand All @@ -83,6 +87,7 @@ impl ProjectExecutor {
install_writer_fence(savepoint, install)
}

#[hotpath::measure(label = "rusqlite.project.observation_cursor_advance")]
pub fn execute_observation_cursor_advance(
&mut self,
savepoint: &Savepoint<'_>,
Expand Down Expand Up @@ -113,6 +118,7 @@ impl ProjectExecutor {
.map(|_| ())
}

#[hotpath::measure(label = "rusqlite.project.evidence_assembly_write")]
pub fn execute_evidence_assembly_write(
&mut self,
savepoint: &Savepoint<'_>,
Expand Down Expand Up @@ -184,6 +190,7 @@ impl ProjectExecutor {
.execute_derivative_write(savepoint, derivative)
}

#[hotpath::measure(label = "rusqlite.project.read")]
pub fn execute_read(
&mut self,
snapshot: &Transaction<'_>,
Expand Down
3 changes: 3 additions & 0 deletions crates/tracedecay-rusqlite-runtime/src/repository/remote.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use tracedecay_store::{RemoteObservationReplayWriteV1, RemoteWriterFenceInstallV

use super::support::{encode, invalid};

#[hotpath::measure(label = "rusqlite.remote.fence_verify_seed")]
pub(super) fn verify_and_seed_writer_fence(
savepoint: &Savepoint<'_>,
write: &RemoteObservationReplayWriteV1,
Expand Down Expand Up @@ -44,6 +45,7 @@ pub(super) fn verify_and_seed_writer_fence(
Ok(())
}

#[hotpath::measure(label = "rusqlite.remote.observation_event_persist")]
pub(super) fn persist_remote_observation_event(
savepoint: &Savepoint<'_>,
write: &RemoteObservationReplayWriteV1,
Expand Down Expand Up @@ -133,6 +135,7 @@ pub(super) fn persist_remote_observation_event(
Ok(())
}

#[hotpath::measure(label = "rusqlite.remote.fence_install")]
pub(super) fn install_writer_fence(
savepoint: &Savepoint<'_>,
install: &RemoteWriterFenceInstallV1,
Expand Down
Loading
Loading