mirror of
https://github.com/ClementTsang/bottom.git
synced 2025-09-23 01:38:37 +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
|
### Bug Fixes
|
||||||
|
|
||||||
- [#1776](https://github.com/ClementTsang/bottom/pull/1776): Fix `disk.columns` being incorrectly interpreted as blank.
|
- [#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
|
## [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) {
|
pub fn update_data(&mut self) {
|
||||||
self.data.collection_time = Instant::now();
|
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::logging::*;
|
||||||
use utils::{cancellation_token::CancellationToken, conversion::*};
|
use utils::{cancellation_token::CancellationToken, conversion::*};
|
||||||
|
|
||||||
|
use crate::collection::Data;
|
||||||
|
|
||||||
// Used for heap allocation debugging purposes.
|
// Used for heap allocation debugging purposes.
|
||||||
// #[global_allocator]
|
// #[global_allocator]
|
||||||
// static ALLOC: dhat::Alloc = dhat::Alloc;
|
// static ALLOC: dhat::Alloc = dhat::Alloc;
|
||||||
@ -222,12 +224,18 @@ fn create_collection_thread(
|
|||||||
let update_sleep = app_config_fields.update_rate;
|
let update_sleep = app_config_fields.update_rate;
|
||||||
|
|
||||||
thread::spawn(move || {
|
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_collector.set_collection(used_widget_set);
|
||||||
data_state.set_use_current_cpu_total(use_current_cpu_total);
|
data_collector.set_use_current_cpu_total(use_current_cpu_total);
|
||||||
data_state.set_unnormalized_cpu(unnormalized_cpu);
|
data_collector.set_unnormalized_cpu(unnormalized_cpu);
|
||||||
data_state.set_show_average_cpu(show_average_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 {
|
loop {
|
||||||
// Check once at the very top... don't block though.
|
// 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:?}");
|
// trace!("Received message in collection thread: {message:?}");
|
||||||
match message {
|
match message {
|
||||||
CollectionThreadEvent::Reset => {
|
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!
|
// Yet another check to bail if needed... do not block!
|
||||||
if let Some(is_terminated) = cancellation_token.try_check() {
|
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));
|
let event = BottomEvent::Update(Box::from(data_collector.data));
|
||||||
data_state.data = collection::Data::default();
|
data_collector.data = Data::default();
|
||||||
|
|
||||||
if sender.send(event).is_err() {
|
if sender.send(event).is_err() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user