Skip to content
Open
6 changes: 3 additions & 3 deletions storage/conformance.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ hash = "13b3e99a8c74b50dc18150194a92306de670b94e6642758feb6d9b6e9881f827"

["commonware_storage::journal::conformance::ContiguousFixed"]
n_cases = 512
hash = "b193d460f527eb5e6f54e6bfc0819aefac1e7b58367464e10e45f0c14d5805e9"
hash = "037ee738320c79885a2e0a750bbb2d5ee62f3270c631b2874b8cc9e9ebe3eee7"

["commonware_storage::journal::conformance::ContiguousVariable"]
n_cases = 512
hash = "4345d35c8fe6fbfb3b76d6a487a864085637163f6a70a7eaa288bea469e842ed"
hash = "6604e1cf727e7894187fa5ed95a655048abfe40822f132075925fe140bfea93a"

["commonware_storage::journal::conformance::SegmentedFixed"]
n_cases = 512
Expand Down Expand Up @@ -356,4 +356,4 @@ hash = "290187801284530d0d7e82c33bb6ce975a5f4daa4b104230291cea9cffcd7686"

["commonware_storage::queue::conformance::QueueConformance"]
n_cases = 512
hash = "718a6b9f3905c146aa0d95b2b32ea1557680940c3fe2a293b73a19a56a3ac000"
hash = "46b87c955c232ab53bc8fdffef26b0f68ed2cc6b435655fbc418949191e3af66"
1,732 changes: 1,404 additions & 328 deletions storage/src/journal/contiguous/fixed.rs

Large diffs are not rendered by default.

23 changes: 22 additions & 1 deletion storage/src/journal/contiguous/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub(super) struct CacheMetrics {
misses: Counter,
}

/// Metrics registered only for variable-size journals.
/// Metrics registered for durable commits.
pub(super) struct CommitMetrics {
/// Durable commit calls that do not fully sync all indexes.
calls: Counter,
Expand Down Expand Up @@ -189,6 +189,7 @@ impl<E: Clock> CommonMetrics<E> {
pub(super) struct FixedMetrics<E: Clock> {
common: CommonMetrics<E>,
cache: CacheMetrics,
commit: CommitMetrics,
}

impl<E: RuntimeMetrics + Clock> FixedMetrics<E> {
Expand All @@ -203,10 +204,22 @@ impl<E: RuntimeMetrics + Clock> FixedMetrics<E> {
"Number of fixed items not satisfied synchronously, including pruned or out-of-range \
try_read_sync probes that returned None",
);
let calls = context
.as_ref()
.counter("commit_calls", "Number of commit calls");
let duration = duration_histogram(
context.as_ref(),
"commit_duration",
"Duration of commit calls",
);
let common = CommonMetrics::new(context);
Self {
common,
cache: CacheMetrics { hits, misses },
commit: CommitMetrics {
calls,
duration: Timed::new(duration),
},
}
}
}
Expand All @@ -219,6 +232,14 @@ impl<E: Clock> FixedMetrics<E> {
pub(super) fn record_cache_misses(&self, misses: u64) {
self.cache.misses.inc_by(misses);
}

pub(super) fn commit_timer(&self) -> ScopedTimer<E> {
self.commit.duration.scoped(&self.common.clock)
}

pub(super) fn record_commit(&self) {
self.commit.calls.inc();
}
}

impl<E: Clock> Deref for FixedMetrics<E> {
Expand Down
12 changes: 6 additions & 6 deletions storage/src/journal/contiguous/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ mod tests;

/// A reader guard that holds a consistent view of the journal.
///
/// While this guard exists, operations that may modify the bounds (such as `append`, `prune`, and
/// `rewind`) will block until the guard is dropped. This keeps bounds stable, so any position
/// within `bounds()` is guaranteed readable.
//
// TODO(<https://github.com/commonwarexyz/monorepo/issues/3084>): Relax locking to allow `append`
// since it doesn't invalidate reads within the cached bounds.
/// While this guard exists, the reader's logical bounds remain stable, and any position within
/// `bounds()` remains readable through this guard.
///
/// Implementations may still make physical storage progress, such as unlinking backing blobs from
/// future namespace lookups, but they must not invalidate reads within the captured bounds or
/// change the bounds visible through this reader.
pub trait Reader: Send + Sync {
/// The type of items stored in the journal.
type Item;
Expand Down
Loading
Loading