proxmox-rrd: use a journal to reduce amount of bytes written
Append pending changes in a simple text based format that allows for lockless appends as long as we stay below 4 KiB data per write. Apply the journal every 30 minutes and on daemon startup. Note that we do not ensure that the journal is synced, this is a perfomance optimization we can make as the kernel defaults to writeback in-flight data every 30s (sysctl vm/dirty_expire_centisecs) anyway, so we lose at max half a minute of data on a crash, here one should have in mind that we normally expose 1 minute as finest granularity anyway, so not really much lost. Signed-off-by: Dietmar Maurer <dietmar@proxmox.com> Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
committed by
Thomas Lamprecht
parent
890b88cbef
commit
1d44f175c6
@ -336,6 +336,36 @@ impl RRD {
|
||||
replace_file(filename, rrd_slice, options)
|
||||
}
|
||||
|
||||
pub fn last_update(&self) -> f64 {
|
||||
|
||||
let mut last_update = 0.0;
|
||||
|
||||
{
|
||||
let mut check_last_update = |rra: &RRA| {
|
||||
if rra.last_update > last_update {
|
||||
last_update = rra.last_update;
|
||||
}
|
||||
};
|
||||
|
||||
check_last_update(&self.hour_avg);
|
||||
check_last_update(&self.hour_max);
|
||||
|
||||
check_last_update(&self.day_avg);
|
||||
check_last_update(&self.day_max);
|
||||
|
||||
check_last_update(&self.week_avg);
|
||||
check_last_update(&self.week_max);
|
||||
|
||||
check_last_update(&self.month_avg);
|
||||
check_last_update(&self.month_max);
|
||||
|
||||
check_last_update(&self.year_avg);
|
||||
check_last_update(&self.year_max);
|
||||
}
|
||||
|
||||
last_update
|
||||
}
|
||||
|
||||
/// Update the value (in memory)
|
||||
///
|
||||
/// Note: This does not call [Self::save].
|
||||
|
Reference in New Issue
Block a user