mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-09-23 09:48:25 +02:00
bug: fix reported usage spike at the start on some OSes (#1788)
* bug: fix spike at the start on some OSes * add clean * bake things in better I guess * hmmm no nvm * tiny sleep * update changelog
This commit is contained in:
parent
849edf71db
commit
f846fdcc05
@ -25,7 +25,11 @@ That said, these are more guidelines rather than hardset rules, though the proje
|
||||
### Bug Fixes
|
||||
|
||||
- [#1776](https://github.com/ClementTsang/bottom/pull/1776): Fix `disk.columns` being incorrectly interpreted as blank.
|
||||
- [1787](https://github.com/ClementTsang/bottom/pull/1787): Fix issue with battery widget time and small widths.
|
||||
- [#1787](https://github.com/ClementTsang/bottom/pull/1787): Fix issue with battery widget time and small widths.
|
||||
|
||||
### Other
|
||||
|
||||
- [#1779](https://github.com/ClementTsang/bottom/pull/1779), [#1788](https://github.com/ClementTsang/bottom/pull/1788): Speed up time between startup and displaying data.
|
||||
|
||||
## [0.11.0] - 2025-08-05
|
||||
|
||||
|
@ -335,6 +335,9 @@ impl DataCollector {
|
||||
}
|
||||
}
|
||||
|
||||
/// Update and refresh data.
|
||||
///
|
||||
/// TODO: separate refresh steps and update steps
|
||||
pub fn update_data(&mut self) {
|
||||
self.data.collection_time = Instant::now();
|
||||
|
||||
|
27
src/lib.rs
27
src/lib.rs
@ -53,6 +53,8 @@ use tui::{Terminal, backend::CrosstermBackend};
|
||||
use utils::logging::*;
|
||||
use utils::{cancellation_token::CancellationToken, conversion::*};
|
||||
|
||||
use crate::collection::Data;
|
||||
|
||||
// Used for heap allocation debugging purposes.
|
||||
// #[global_allocator]
|
||||
// static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||
@ -222,12 +224,18 @@ fn create_collection_thread(
|
||||
let update_sleep = app_config_fields.update_rate;
|
||||
|
||||
thread::spawn(move || {
|
||||
let mut data_state = collection::DataCollector::new(filters);
|
||||
let mut data_collector = collection::DataCollector::new(filters);
|
||||
|
||||
data_state.set_collection(used_widget_set);
|
||||
data_state.set_use_current_cpu_total(use_current_cpu_total);
|
||||
data_state.set_unnormalized_cpu(unnormalized_cpu);
|
||||
data_state.set_show_average_cpu(show_average_cpu);
|
||||
data_collector.set_collection(used_widget_set);
|
||||
data_collector.set_use_current_cpu_total(use_current_cpu_total);
|
||||
data_collector.set_unnormalized_cpu(unnormalized_cpu);
|
||||
data_collector.set_show_average_cpu(show_average_cpu);
|
||||
|
||||
data_collector.update_data();
|
||||
data_collector.data = Data::default();
|
||||
|
||||
// Tiny sleep I guess? To go between the first update above and the first update in the loop.
|
||||
std::thread::sleep(Duration::from_millis(5));
|
||||
|
||||
loop {
|
||||
// Check once at the very top... don't block though.
|
||||
@ -241,12 +249,12 @@ fn create_collection_thread(
|
||||
// trace!("Received message in collection thread: {message:?}");
|
||||
match message {
|
||||
CollectionThreadEvent::Reset => {
|
||||
data_state.data.cleanup();
|
||||
data_collector.data.cleanup();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
data_state.update_data();
|
||||
data_collector.update_data();
|
||||
|
||||
// Yet another check to bail if needed... do not block!
|
||||
if let Some(is_terminated) = cancellation_token.try_check() {
|
||||
@ -255,8 +263,9 @@ fn create_collection_thread(
|
||||
}
|
||||
}
|
||||
|
||||
let event = BottomEvent::Update(Box::from(data_state.data));
|
||||
data_state.data = collection::Data::default();
|
||||
let event = BottomEvent::Update(Box::from(data_collector.data));
|
||||
data_collector.data = Data::default();
|
||||
|
||||
if sender.send(event).is_err() {
|
||||
break;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user