Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: points rework (v1) #1663

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
cb3f7a7
refactor: add new method of storing timeseries data
ClementTsang Dec 26, 2024
e6b1aaf
mostly finish adding data
ClementTsang Dec 26, 2024
6d63f9e
tmp
ClementTsang Jan 6, 2025
f697c8f
migrate over to separate lib
ClementTsang Jan 12, 2025
1490581
prepare to migrate over to new timeseries storage
ClementTsang Jan 12, 2025
6dc4946
prepare to migrate frozen state
ClementTsang Jan 13, 2025
e6a14fd
migrate frozen state
ClementTsang Jan 16, 2025
bf85e7e
name
ClementTsang Jan 16, 2025
9265319
migrate data collection
ClementTsang Jan 16, 2025
4385f57
migrate network
ClementTsang Jan 16, 2025
9d3c9ba
fix some stuff
ClementTsang Jan 16, 2025
25881f3
fix a panic from bad pruning
ClementTsang Jan 16, 2025
99ade9d
Fix pruning issues
ClementTsang Jan 17, 2025
3986175
migrate RAM
ClementTsang Jan 18, 2025
7675f6e
migrate swap
ClementTsang Jan 18, 2025
44bb8fb
migrate cache label
ClementTsang Jan 18, 2025
040a965
refactor out to function
ClementTsang Jan 18, 2025
e07d9ff
migrate ram points
ClementTsang Jan 18, 2025
6974b7b
migrate swap points
ClementTsang Jan 19, 2025
e4ff80a
migrate cache points
ClementTsang Jan 19, 2025
15aae70
migrate arc
ClementTsang Jan 19, 2025
9a8e224
migrate gpu, remove a bunch of state code around force update
ClementTsang Jan 19, 2025
88f4376
rename cache, also some comments
ClementTsang Jan 19, 2025
db80100
some temp cleanup
ClementTsang Jan 19, 2025
86853a0
migrate disk
ClementTsang Jan 19, 2025
e4c531f
comments to remind me above fixmes, fix bug around time graph spans
ClementTsang Jan 19, 2025
eb838f0
migrate load avg
ClementTsang Jan 19, 2025
4bee13b
port temps
ClementTsang Jan 19, 2025
e67806e
style
ClementTsang Jan 20, 2025
85549ca
fix bug wiwth left edge gap
ClementTsang Jan 20, 2025
40a43ee
partial migration of cpu, reorganize data file structure
ClementTsang Jan 20, 2025
9b8f33d
migrate cpu
ClementTsang Jan 20, 2025
ec562f2
some cleanup
ClementTsang Jan 20, 2025
7ee4878
fix bug with cpu widget + clippy
ClementTsang Jan 20, 2025
fbbd100
start some small optimization work
ClementTsang Jan 20, 2025
408e81c
fix some things for some platforms
ClementTsang Jan 20, 2025
a41142a
refactor: rename data_collection to collection
ClementTsang Jan 20, 2025
c3365be
refactor: only process temp type in data eat step
ClementTsang Jan 25, 2025
8e3c5da
flatten components folder a bit
ClementTsang Jan 26, 2025
12f831b
partially migrate to new graph system and fix cpu bug
ClementTsang Jan 26, 2025
0b7a689
driveby migration of process list to reduce allocs + more migration o…
ClementTsang Jan 29, 2025
9ffaebe
revert the collection change
ClementTsang Jan 29, 2025
3564f8b
port over network stuff...
ClementTsang Jan 31, 2025
c633dcd
fully migrate network, and fix some log bugs while we're at it
ClementTsang Jan 31, 2025
fb956e2
fix cpu colour in all mode
ClementTsang Feb 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,17 @@ That said, these are more guidelines rather than hardset rules, though the proje
- [#1593](https://github.com/ClementTsang/bottom/pull/1593): Fix using `"none"` for chart legend position in configs.
- [#1594](https://github.com/ClementTsang/bottom/pull/1594): Fix incorrect default config definitions for chart legends.
- [#1596](https://github.com/ClementTsang/bottom/pull/1596): Fix support for nilfs2 file system.
- [#1660](https://github.com/ClementTsang/bottom/pull/1660): Handle terminal cleanup if the program is terminated due to an `Err` bubbling to the top.
- [#1660](https://github.com/ClementTsang/bottom/pull/1660): Fix properly cleaning up the terminal if the program is terminated due to an `Err` bubbling to the top.
- [#1663](https://github.com/ClementTsang/bottom/pull/1663): Fix network graphs using log scaling having broken lines when a point was 0.

### Changes

- [#1559](https://github.com/ClementTsang/bottom/pull/1559): Rename `--enable_gpu` to `--disable_gpu`, and make GPU features enabled by default.
- [#1570](https://github.com/ClementTsang/bottom/pull/1570): Consider `$XDG_CONFIG_HOME` on macOS when looking for a default config path in a
backwards-compatible fashion.
- [#1570](https://github.com/ClementTsang/bottom/pull/1570): Consider `$XDG_CONFIG_HOME` on macOS when looking for a default config path in a backwards-compatible fashion.

### Other

- [#1663](https://github.com/ClementTsang/bottom/pull/1663): Rework how data is stored internally, reducing memory usage a bit.

## [0.10.2] - 2024-08-05

Expand Down
7 changes: 7 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ regex = "1.11.1"
serde = { version = "1.0.217", features = ["derive"] }
starship-battery = { version = "0.10.0", optional = true }
sysinfo = "=0.30.13"
timeless = "0.0.14-alpha"
toml_edit = { version = "0.22.22", features = ["serde"] }
tui = { version = "0.29.0", package = "ratatui" }
unicode-ellipsis = "0.3.0"
Expand Down
168 changes: 48 additions & 120 deletions src/app.rs

Large diffs are not rendered by default.

13 changes: 13 additions & 0 deletions src/app/data/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//! How we manage data internally.

mod time_series;
pub use time_series::{TimeSeriesData, Values};

mod process;
pub use process::ProcessData;

mod store;
pub use store::*;

mod temperature;
pub use temperature::*;
54 changes: 54 additions & 0 deletions src/app/data/process.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
use std::{collections::BTreeMap, vec::Vec};

use crate::collection::processes::{Pid, ProcessHarvest};
use hashbrown::HashMap;

#[derive(Clone, Debug, Default)]
pub struct ProcessData {
/// A PID to process data map.
pub process_harvest: BTreeMap<Pid, ProcessHarvest>,

/// A mapping between a process PID to any children process PIDs.
pub process_parent_mapping: HashMap<Pid, Vec<Pid>>,

/// PIDs corresponding to processes that have no parents.
pub orphan_pids: Vec<Pid>,
}

impl ProcessData {
pub(super) fn ingest(&mut self, list_of_processes: Vec<ProcessHarvest>) {
self.process_parent_mapping.clear();

// Reverse as otherwise the pid mappings are in the wrong order.
list_of_processes.iter().rev().for_each(|process_harvest| {
if let Some(parent_pid) = process_harvest.parent_pid {
if let Some(entry) = self.process_parent_mapping.get_mut(&parent_pid) {
entry.push(process_harvest.pid);
} else {
self.process_parent_mapping
.insert(parent_pid, vec![process_harvest.pid]);
}
}
});

self.process_parent_mapping.shrink_to_fit();

let process_pid_map = list_of_processes
.into_iter()
.map(|process| (process.pid, process))
.collect();
self.process_harvest = process_pid_map;

// We collect all processes that either:
// - Do not have a parent PID (that is, they are orphan processes)
// - Have a parent PID but we don't have the parent (we promote them as orphans)
self.orphan_pids = self
.process_harvest
.iter()
.filter_map(|(pid, process_harvest)| match process_harvest.parent_pid {
Some(parent_pid) if self.process_harvest.contains_key(&parent_pid) => None,
_ => Some(*pid),
})
.collect();
}
}
Loading
Loading