Chart session checkpoints as their own cache bucket
This commit is contained in:
@@ -371,21 +371,25 @@ impl App {
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Disc usage of both cache buckets, split by age. The bar is the age
|
||||
/// distribution of what is stored; the budget governs the transient store
|
||||
/// only and is reported on its own row.
|
||||
/// Disc usage of both cache buckets. The bar splits the transient store by
|
||||
/// age — the order the budget evicts in — and carries the session
|
||||
/// checkpoints as one further segment, since those are only freed with
|
||||
/// their session and so compete for disc without ever ageing out.
|
||||
fn cache_explorer(&self) -> Element<'_, Message> {
|
||||
let usage = &self.kv_cache_report;
|
||||
let total = usage.total_bytes();
|
||||
let capacity = total.max(1);
|
||||
let segments = crate::metrics::CACHE_AGE_BUCKETS
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(index, (label, _))| (*label, usage.age_bytes[index], AGE_COLORS[index]))
|
||||
.chain([("Sessions", usage.session_bytes, SESSION_COLOR)]);
|
||||
let mut bar = row![].height(14).spacing(2);
|
||||
let mut legend = column![].spacing(6);
|
||||
for (index, (label, _)) in crate::metrics::CACHE_AGE_BUCKETS.iter().enumerate() {
|
||||
let bytes = usage.age_bytes[index];
|
||||
for (label, bytes, color) in segments {
|
||||
if bytes == 0 {
|
||||
continue;
|
||||
}
|
||||
let color = AGE_COLORS[index];
|
||||
bar = bar.push(
|
||||
container(Space::new(Length::Fill, Length::Fill))
|
||||
.width(Length::FillPortion(portion(bytes, capacity)))
|
||||
@@ -394,7 +398,7 @@ impl App {
|
||||
legend = legend.push(
|
||||
row![
|
||||
container(Space::new(9, 9)).style(move |_| chart_bar_style(color)),
|
||||
text(*label).size(12).color(muted_text()),
|
||||
text(label).size(12).color(muted_text()),
|
||||
Space::with_width(Length::Fill),
|
||||
text(format!(
|
||||
"{} · {:.0}%",
|
||||
@@ -497,6 +501,9 @@ impl App {
|
||||
}
|
||||
}
|
||||
|
||||
/// Sessions sit outside the age scale: they are not evicted, only deleted.
|
||||
const SESSION_COLOR: Color = Color::from_rgb(0.85, 0.44, 0.56);
|
||||
|
||||
/// Age buckets from green (fresh) to grey (past every hit half-life).
|
||||
const AGE_COLORS: [Color; 5] = [
|
||||
Color::from_rgb(0.28, 0.69, 0.44),
|
||||
|
||||
Reference in New Issue
Block a user