Skip to content
Merged
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
61 changes: 37 additions & 24 deletions quickwit/quickwit-storage/src/split_cache/split_table.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ impl SplitTable {
status: Status::OnDisk { num_bytes },
};
self.insert(split_info);
record_split_added_to_disk(num_bytes);
}
}
}
Expand All @@ -144,6 +145,36 @@ fn compute_timestamp(start: Instant) -> LastAccessDate {
start.elapsed().as_micros() as u64
}

fn record_split_added_to_disk(num_bytes: u64) {
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_count
.inc();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_num_bytes
.add(num_bytes as i64);
}

fn record_split_evicted(num_bytes: u64) {
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_count
.dec();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_num_bytes
.sub(num_bytes as i64);
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.evict_num_items
.inc();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.evict_num_bytes
.inc_by(num_bytes);
}

impl SplitTable {
fn remove(&mut self, split_ulid: Ulid) -> Option<SplitInfo> {
let split_info = self.split_to_status.remove(&split_ulid)?;
Expand All @@ -152,22 +183,6 @@ impl SplitTable {
Status::Downloading { .. } => &mut self.downloading_splits,
Status::OnDisk { num_bytes } => {
self.on_disk_bytes -= num_bytes;
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_count
.dec();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_num_bytes
.sub(num_bytes as i64);
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.evict_num_items
.inc();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.evict_num_bytes
.inc_by(num_bytes);
Comment on lines -155 to -170

@rdettai-sk rdettai-sk Jul 3, 2026

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the issue here was that remove is called for mutations that don't necessarily imply an eviction (the split is usually added back before releasing the lock

&mut self.on_disk_splits
}
};
Expand Down Expand Up @@ -216,14 +231,6 @@ impl SplitTable {
Status::Downloading { .. } => self.downloading_splits.insert(split_info.split_key),
Status::OnDisk { num_bytes } => {
self.on_disk_bytes += num_bytes;
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_count
.inc();
crate::metrics::STORAGE_METRICS
.searcher_split_cache
.in_cache_num_bytes
.add(num_bytes as i64);
self.on_disk_splits.insert(split_info.split_key)
}
};
Expand Down Expand Up @@ -335,6 +342,7 @@ impl SplitTable {

pub(crate) fn register_as_downloaded(&mut self, split_ulid: Ulid, num_bytes: u64) {
self.change_split_status(split_ulid, Status::OnDisk { num_bytes });
record_split_added_to_disk(num_bytes);
}

/// Change the state of the given split from candidate to downloading state,
Expand Down Expand Up @@ -406,6 +414,11 @@ impl SplitTable {
}
Err(NoRoomAvailable)
} else {
for split_info in &split_infos {
if let Status::OnDisk { num_bytes } = split_info.status {
record_split_evicted(num_bytes);
}
}
Comment thread
rdettai-sk marked this conversation as resolved.
Ok(split_infos
.into_iter()
.map(|split_info| split_info.split_key.split_ulid)
Expand Down
Loading