Skip to content

Commit cd8efd5

Browse files
authored
Merge pull request #216 from fjall-rs/feat/index-block/block-handle-seqno
wip
2 parents 7409d26 + cae7478 commit cd8efd5

File tree

4 files changed

+31
-8
lines changed

4 files changed

+31
-8
lines changed

src/cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ impl Cache {
8888
#[expect(clippy::expect_used, reason = "nothing we can do if it fails")]
8989
let opts = quick_cache::OptionsBuilder::new()
9090
.weight_capacity(bytes)
91-
.hot_allocation(0.5)
92-
.estimated_items_capacity(1_000)
91+
.hot_allocation(0.8)
92+
.estimated_items_capacity(10_000)
9393
.build()
9494
.expect("cache options should be valid");
9595

src/config/mod.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ pub use hash_ratio::HashRatioPolicy;
1616
pub use pinning::PinningPolicy;
1717
pub use restart_interval::RestartIntervalPolicy;
1818

19-
/// Partioning policy for indexes and filters
20-
pub type PartioningPolicy = PinningPolicy;
19+
/// Partitioning policy for indexes and filters
20+
pub type PartitioningPolicy = PinningPolicy;
2121

2222
use crate::{
2323
path::absolute_path, version::DEFAULT_LEVEL_COUNT, AnyTree, BlobTree, Cache, CompressionType,
@@ -209,10 +209,10 @@ pub struct Config {
209209
pub data_block_hash_ratio_policy: HashRatioPolicy,
210210

211211
/// Whether to partition index blocks
212-
pub index_block_partitioning_policy: PartioningPolicy,
212+
pub index_block_partitioning_policy: PartitioningPolicy,
213213

214214
/// Whether to partition filter blocks
215-
pub filter_block_partitioning_policy: PartioningPolicy,
215+
pub filter_block_partitioning_policy: PartitioningPolicy,
216216

217217
/// Partition size when using partitioned indexes
218218
pub index_block_partition_size_policy: BlockSizePolicy,

src/config/pinning.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,19 @@ impl PinningPolicy {
2222
.unwrap_or_else(|| self.last().copied().expect("policy should not be empty"))
2323
}
2424

25-
/// Uses the same block size in every level.
25+
/// Uses the same policy in every level.
2626
#[must_use]
2727
pub fn all(c: bool) -> Self {
2828
Self(vec![c])
2929
}
3030

31-
/// Constructs a custom block size policy.
31+
/// Fully disables pinning.
32+
#[must_use]
33+
pub fn disabled() -> Self {
34+
Self::all(false)
35+
}
36+
37+
/// Constructs a custom policy.
3238
#[must_use]
3339
pub fn new(policy: impl Into<Vec<bool>>) -> Self {
3440
let policy = policy.into();

src/metrics.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,11 @@ impl Metrics {
111111
+ self.filter_block_load_io.load(Relaxed)
112112
}
113113

114+
/// Number of data blocks that were loaded from disk or OS page cache.
115+
pub fn data_block_load_cached_count(&self) -> usize {
116+
self.data_block_load_cached.load(Relaxed)
117+
}
118+
114119
/// Number of index blocks that were loaded from disk or OS page cache.
115120
pub fn index_block_load_cached_count(&self) -> usize {
116121
self.index_block_load_cached.load(Relaxed)
@@ -133,6 +138,18 @@ impl Metrics {
133138
self.block_load_io_count() + self.block_load_cached_count()
134139
}
135140

141+
/// Data block cache efficiency in percent (0.0 - 1.0).
142+
pub fn data_block_cache_hit_rate(&self) -> f64 {
143+
let queries = self.data_block_load_count() as f64;
144+
let hits = self.data_block_load_cached_count() as f64;
145+
146+
if queries == 0.0 {
147+
1.0
148+
} else {
149+
hits / queries
150+
}
151+
}
152+
136153
/// Filter block cache efficiency in percent (0.0 - 1.0).
137154
pub fn filter_block_cache_hit_rate(&self) -> f64 {
138155
let queries = self.filter_block_load_count() as f64;

0 commit comments

Comments
 (0)