Debian Codegraph @

src/app/data/time_series.rs

raw symbols SCIP
1 //! Time series data.
2
3 use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::{
4 cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/::Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#,
5 timerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/::{Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#, Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#},
6 vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/::Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#,
7 };
8
9 use rustc_hashrust-analyzer cargo rustc-hash 2.1.3 crate/::{FxHashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap# as HashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#, FxHashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet# as HashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#};
10 use timelessrust-analyzer cargo timeless 0.1.0 crate/::datarust-analyzer cargo timeless 0.1.0 data/::ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#;
11
12 use craterust-analyzer cargo bottom 0.14.9 crate/::{
13 apprust-analyzer cargo bottom 0.14.9 app/::{AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#, DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters#, filterrust-analyzer cargo bottom 0.14.9 app/filter/::Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#, layout_managerrust-analyzer cargo bottom 0.14.9 app/layout_manager/::UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#},
14 collectionrust-analyzer cargo bottom 0.14.9 collection/::Datarust-analyzer cargo bottom 0.14.9 collection/Data#,
15 widgetsrust-analyzer cargo bottom 0.14.9 widgets/::DiskWidgetDatarust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#,
16 };
17
18 /// Values corresponding to a time slice.
19 pub type Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values# = ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<f64>;
20
21 /// Represents time series data in a chunked, deduped manner.
22 ///
23 /// Properties:
24 /// - Time in this manner is represented in a reverse-offset fashion from the
25 /// current time.
26 /// - All data is stored in SoA fashion.
27 /// - Values are stored in a chunked format, which facilitates gaps in data
28 /// collection if needed.
29 /// - Additional metadata is stored to make data pruning over time easy.
30 #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Clonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core clone/Clone:, Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default:)]
31 pub struct TimeSeriesDatarust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData# {
32 /// Time values.
33 ///
34 /// TODO: (points_rework_v1) Either store millisecond-level only or offsets
35 /// only.
36 pub timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#>,
37
38 /// Network RX data.
39 pub rxrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#rx.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
40
41 /// Network TX data.
42 pub txrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#tx.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
43
44 /// CPU data.
45 pub cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu.: Vecrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/Vec#<Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#>,
46
47 /// RAM memory data.
48 pub ramrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#ram.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
49
50 /// Swap data.
51 pub swaprust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#swap.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
52
53 #[cfg(not(target_os = "windows"))]
54 /// Cache data.
55 pub cache_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cache_mem.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
56
57 #[cfg(feature = "zfs")]
58 /// Arc data.
59 pub arc_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#arc_mem.: Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#,
60
61 #[cfg(feature = "gpu")]
62 /// GPU memory data.
63 pub gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem.: HashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, Valuesrust-analyzer cargo bottom 0.14.9 app/data/time_series/Values#>,
64
65 /// Temperature data.
66 ///
67 /// TODO: Maybe make this use TypedTemperature?
68 pub temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature.: HashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<f32>>,
69
70 /// Disk I/O read rate data, keyed by device name.
71 pub disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read.: HashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<f64>>,
72
73 /// Disk I/O write rate data, keyed by device name.
74 pub disk_io_writerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_write.: HashMaprust-analyzer cargo rustc-hash 2.1.3 FxHashMap#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#<f64>>,
75 }
76
77 impl TimeSeriesDatarust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData# {
78 /// Add a new data point.
79 pub fn addrust-analyzer cargo bottom 0.14.9 app/data/time_series/impl#[TimeSeriesData]add().(
80 &mut self, data: &Datarust-analyzer cargo bottom 0.14.9 collection/Data#, used_widgets: &UsedWidgetsrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#, settings: &AppConfigFieldsrust-analyzer cargo bottom 0.14.9 app/AppConfigFields#,
81 filters: &DataFiltersrust-analyzer cargo bottom 0.14.9 app/DataFilters#,
82 ) {
83 self.timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(data.collection_timerust-analyzer cargo bottom 0.14.9 collection/Data#collection_time.);
84
85 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(network) = &data.networkrust-analyzer cargo bottom 0.14.9 collection/Data#network. {
86 self.rxrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#rx..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(network.rxrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#rx. as f64);
87 self.txrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#tx..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(network.txrust-analyzer cargo bottom 0.14.9 collection/network/NetworkHarvest#tx. as f64);
88 } else {
89 self.rxrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#rx..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
90 self.txrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#tx..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
91 }
92
93 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cpu) = &data.cpurust-analyzer cargo bottom 0.14.9 collection/Data#cpu. {
94 match self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().().cmprust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][Ord]cmp().(&cpu.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().()) {
95 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Lessrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Less# => {
96 let diff = cpu.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
97 self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..reserve_exactrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]reserve_exact().(diff);
98
99 for _ in 0..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/Range#diff {
100 self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..pushrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]push().(Defaultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core default/Default#::defaultrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`][Default]default().());
101 }
102 }
103 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Greaterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Greater# => {
104 let diff = self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().cpu.lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().();
105 let offset = self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..lenrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]len().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().diff;
106
107 for curr in &mut self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu.[rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut().offset..rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeFrom#]rust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`][`IndexMut<I>`]index_mut(). {
108 curr.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
109 }
110 }
111 Orderingrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#::Equalrust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/Ordering#Equal# => {}
112 }
113
114 for (curr, new_data) in self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu..iter_mutrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter_mut().().ziprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#zip().(cpu.iterrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]iter().()) {
115 curr.pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(new_data.usagerust-analyzer cargo bottom 0.14.9 collection/cpu/CpuData#usage..intorust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/impl#[T][`Into<U>`]into().());
116 }
117 } else {
118 for c in &mut self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu. {
119 c.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
120 }
121 }
122
123 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(memory) = &data.memoryrust-analyzer cargo bottom 0.14.9 collection/Data#memory. {
124 self.ramrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#ram..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(memory.percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().());
125 } else {
126 self.ramrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#ram..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
127 }
128
129 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(swap) = &data.swaprust-analyzer cargo bottom 0.14.9 collection/Data#swap. {
130 self.swaprust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#swap..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(swap.percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().());
131 } else {
132 self.swaprust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#swap..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
133 }
134
135 #[cfg(not(target_os = "windows"))]
136 {
137 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(cache) = &data.cacherust-analyzer cargo bottom 0.14.9 collection/Data#cache. {
138 self.cache_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cache_mem..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(cache.percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().());
139 } else {
140 self.cache_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cache_mem..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
141 }
142 }
143
144 #[cfg(feature = "zfs")]
145 {
146 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(arc) = &data.arcrust-analyzer cargo bottom 0.14.9 collection/Data#arc. {
147 self.arc_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#arc_mem..pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(arc.percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().());
148 } else {
149 self.arc_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#arc_mem..insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
150 }
151 }
152
153 #[cfg(feature = "gpu")]
154 {
155 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(gpu) = &data.gpurust-analyzer cargo bottom 0.14.9 collection/Data#gpu. {
156 let mut not_visited = self
157 .gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem.
158 .keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().()
159 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().)
160 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<HashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#<_>>();
161
162 for (name, new_data) in gpu {
163 not_visited.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(name);
164
165 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(name) {
166 self.gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem.
167 .insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(name.to_stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[T][ToString]to_string().(), ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#::defaultrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`][Default]default().());
168 }
169
170 let curr = self
171 .gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem.
172 .get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(name)
173 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("entry must exist as it was created above");
174 curr.pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(new_data.percentagerust-analyzer cargo bottom 0.14.9 collection/memory/impl#[MemData]percentage().());
175 }
176
177 for nv in not_visited {
178 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = self.gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&nv) {
179 entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
180 }
181 }
182 } else {
183 for g in self.gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem..values_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values_mut().() {
184 g.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
185 }
186 }
187 }
188
189 if used_widgets.use_temp_graphrust-analyzer cargo bottom 0.14.9 app/layout_manager/UsedWidgets#use_temp_graph. {
190 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(temperature_sensors) = &data.temperature_sensorsrust-analyzer cargo bottom 0.14.9 collection/Data#temperature_sensors. {
191 let mut not_visited = self
192 .temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature.
193 .keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().()
194 .maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#map().(Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#::to_ownedrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc borrow/impl#[T][ToOwned]to_owned().)
195 .collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().::<HashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#<_>>();
196
197 for sensor_data in temperature_sensors {
198 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#::optional_should_keeprust-analyzer cargo bottom 0.14.9 app/filter/impl#[Filter]optional_should_keep().(&filters.temp_graph_filterrust-analyzer cargo bottom 0.14.9 app/DataFilters#temp_graph_filter., &sensor_data.namerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#name.)
199 {
200 continue;
201 }
202
203 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(temperature) = sensor_data.temperaturerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#temperature. {
204 not_visited.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&sensor_data.namerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#name.);
205
206 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().self.temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature..contains_keyrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]contains_key().(&sensor_data.namerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#name.) {
207 self.temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature.
208 .insertrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]insert().(sensor_data.namerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().(), ChunkedDatarust-analyzer cargo timeless 0.1.0 data/chunked/ChunkedData#::defaultrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`][Default]default().());
209 }
210
211 let curr = self
212 .temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature.
213 .get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&sensor_data.namerust-analyzer cargo bottom 0.14.9 collection/temperature/TempSensorData#name.)
214 .expectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]expect().("entry must exist as it was created above");
215
216 let converted_temperature = settings
217 .temperature_typerust-analyzer cargo bottom 0.14.9 app/AppConfigFields#temperature_type.
218 .convert_temp_unit_floatrust-analyzer cargo bottom 0.14.9 app/data/temperature/impl#[TemperatureType]convert_temp_unit_float().(temperature);
219 curr.pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(converted_temperature);
220 }
221 }
222
223 for nv in not_visited {
224 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = self.temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&nv) {
225 entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
226 }
227 }
228 } else {
229 for g in self.temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature..values_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]values_mut().() {
230 g.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
231 }
232 }
233 }
234 }
235
236 /// Update disk I/O time series using already-calculated rates from
237 /// [`DiskWidgetData`]. Devices not present in `disks` get a break inserted
238 /// so the legend keeps them around for the window's remaining lifetime.
239 pub fn update_disk_iorust-analyzer cargo bottom 0.14.9 app/data/time_series/impl#[TimeSeriesData]update_disk_io().(
240 &mut self, disks: &[DiskWidgetDatarust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#], filter: &Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#>, show_unmounted: bool,
241 ) {
242 #[cfg(not(target_os = "linux"))]
243 let _ = show_unmounted;
244
245 let mut not_visited: HashSetrust-analyzer cargo rustc-hash 2.1.3 FxHashSet#<Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#> = self.disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read..keysrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]keys().().clonedrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#cloned().().collectrust-analyzer cargo core https://github.com/rust-lang/rust/library/core iter/traits/iterator/Iterator#collect().();
246
247 for disk in disks {
248 #[cfg(target_os = "linux")]
249 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().show_unmounted && disk.mount_pointrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#mount_point..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String]is_empty().() {
250 continue;
251 }
252
253 if !rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/bit/impl#[bool][Not]not().Filterrust-analyzer cargo bottom 0.14.9 app/filter/Filter#::optional_should_keeprust-analyzer cargo bottom 0.14.9 app/filter/impl#[Filter]optional_should_keep().(filter, &disk.namerust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#name.) {
254 continue;
255 }
256
257 not_visited.removerust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/set/impl#[`HashSet<T, S, A>`]remove().(&disk.namerust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#name.);
258
259 let read_entry = self.disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read..entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(disk.namerust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().();
260 match disk.io_read_rate_bytesrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#io_read_rate_bytes. {
261 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) => read_entry.pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(v as f64),
262 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => read_entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().(),
263 }
264
265 let write_entry = self.disk_io_writerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_write..entryrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]entry().(disk.namerust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#name..clonerust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/impl#[String][Clone]clone().()).or_defaultrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`Entry<'a, K, V>`]or_default().();
266 match disk.io_write_rate_bytesrust-analyzer cargo bottom 0.14.9 widgets/disk_table/DiskWidgetData#io_write_rate_bytes. {
267 Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(v) => write_entry.pushrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]push().(v as f64),
268 Nonerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#None# => write_entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().(),
269 }
270 }
271
272 for name in not_visited {
273 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = self.disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&name) {
274 entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
275 }
276 if let Somerust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#Some#(entry) = self.disk_io_writerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_write..get_mutrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]get_mut().(&name) {
277 entry.insert_breakrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]insert_break().();
278 }
279 }
280 }
281
282 /// Prune any data older than the given duration.
283 pub fn prunerust-analyzer cargo bottom 0.14.9 app/data/time_series/impl#[TimeSeriesData]prune().(&mut self, max_age: Durationrust-analyzer cargo core https://github.com/rust-lang/rust/library/core time/Duration#) {
284 if self.timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time..is_emptyrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]is_empty().() {
285 return;
286 }
287
288 let now = Instantrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/Instant#::nowrust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]now().();
289 let end = {
290 let partition_point = self
291 .timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time.
292 .partition_pointrust-analyzer cargo core https://github.com/rust-lang/rust/library/core slice/impl#[`[T]`]partition_point().(|then| now.duration_sincerust-analyzer cargo std https://github.com/rust-lang/rust/library/std time/impl#[Instant]duration_since().(*rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/deref/impl#[`&T`][Deref]deref().then) rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/PartialOrd#gt().max_age);
293
294 // Partition point returns the first index that does not match the predicate, so
295 // minus one.
296 if partition_point rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().>rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialOrd<Self>`]gt().0 {
297 partition_point rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().-rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/arith/impl#[usize][`Sub<Self>`]sub().1
298 } else {
299 // If the partition point was 0, then it means all values are too new to be
300 // pruned.
301 // crate::info!("Skipping prune.");
302 return;
303 }
304 };
305
306 // crate::info!("Pruning up to index {end}.");
307
308 // Note that end here is _inclusive_.
309 self.timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time..drainrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]drain().(0..=rust-analyzer cargo core https://github.com/rust-lang/rust/library/core ops/range/RangeInclusive#end);
310 self.timerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#time..shrink_to_fitrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc vec/impl#[`Vec<T, A>`]shrink_to_fit().();
311
312 let _ = self.rxrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#rx..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
313 let _ = self.txrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#tx..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
314
315 for cpu in &mut self.cpurust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cpu. {
316 let _ = cpu.prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
317 }
318
319 let _ = self.ramrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#ram..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
320 let _ = self.swaprust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#swap..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
321
322 #[cfg(not(target_os = "windows"))]
323 let _ = self.cache_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#cache_mem..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
324
325 #[cfg(feature = "zfs")]
326 let _ = self.arc_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#arc_mem..prune_and_shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune_and_shrink_to_fit().(end);
327
328 #[cfg(feature = "gpu")]
329 {
330 self.gpu_memrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#gpu_mem..retainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]retain().(|_, gpu| {
331 let _ = gpu.prunerust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune().(end);
332
333 // Remove the entry if it is empty. We can always add it again later.
334 if gpu.no_elementsrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]no_elements().() {
335 false
336 } else {
337 gpu.shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]shrink_to_fit().();
338 true
339 }
340 });
341 }
342
343 self.temperaturerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#temperature..retainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]retain().(|_, data| {
344 let _ = data.prunerust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune().(end);
345
346 // Remove the entry if it is empty. We can always add it again later.
347 if data.no_elementsrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]no_elements().() {
348 false
349 } else {
350 data.shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]shrink_to_fit().();
351 true
352 }
353 });
354
355 self.disk_io_readrust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_read..retainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]retain().(|_, data| {
356 let _ = data.prunerust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune().(end);
357
358 if data.no_elementsrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]no_elements().() {
359 false
360 } else {
361 data.shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]shrink_to_fit().();
362 true
363 }
364 });
365
366 self.disk_io_writerust-analyzer cargo bottom 0.14.9 app/data/time_series/TimeSeriesData#disk_io_write..retainrust-analyzer cargo std https://github.com/rust-lang/rust/library/std collections/hash/map/impl#[`HashMap<K, V, S, A>`]retain().(|_, data| {
367 let _ = data.prunerust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]prune().(end);
368
369 if data.no_elementsrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]no_elements().() {
370 false
371 } else {
372 data.shrink_to_fitrust-analyzer cargo timeless 0.1.0 data/chunked/impl#[`ChunkedData<D>`]shrink_to_fit().();
373 true
374 }
375 });
376 }
377 }