Skip to content

Commit

Permalink
Bump sysinfo from 0.25.2 to 0.26.0 (#712)
Browse files Browse the repository at this point in the history
* Bump sysinfo from 0.25.2 to 0.26.0

Bumps [sysinfo](https://github.com/GuillaumeGomez/sysinfo) from 0.25.2 to 0.26.0.
- [Release notes](https://github.com/GuillaumeGomez/sysinfo/releases)
- [Changelog](https://github.com/GuillaumeGomez/sysinfo/blob/master/CHANGELOG.md)
- [Commits](https://github.com/GuillaumeGomez/sysinfo/commits)

---
updated-dependencies:
- dependency-name: sysinfo
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

* Adjust for sysinfo kb->bytes and increase mem threshold.

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: John Michael Burke <[email protected]>
  • Loading branch information
dependabot[bot] and john-michaelburke authored Aug 31, 2022
1 parent d09651d commit 39e494a
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion console_backend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ ordered-float = "3.0"
ndarray = "0.15.6"
glob = "0.3.0"
criterion = "0.3.6"
sysinfo = "0.25.2"
sysinfo = "0.26.0"
serialport = { git = "https://github.com/swift-nav/serialport-rs.git", default-features = false }
directories = "4"
anyhow = { version = "1", features = ["backtrace"] }
Expand Down
37 changes: 20 additions & 17 deletions console_backend/tests/mem_benches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ mod mem_bench_impl {
const MINIMUM_MEM_READINGS: usize = 20;

const DIFF_THRESHOLD: f32 = 0.25;
const MAXIMUM_MEM_USAGE_KB: f32 = 220000.0;
const ABSOLUTE_MINIMUM_MEM_USAGE: f32 = 1000.0;
const MAXIMUM_MEM_USAGE_BYTES: f32 = 30e6;
const ABSOLUTE_MINIMUM_MEM_USAGE: f32 = 1e6;
const MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM: f32 = 0.5;

/// Convert a 1D Vector to an ArrayView.
Expand Down Expand Up @@ -55,18 +55,21 @@ mod mem_bench_impl {

let mem_read_thread = thread::spawn(move || {
let mut sys = System::new();
let mut mem_readings_kb: Vec<f32> = vec![];
let mut mem_readings_bytes: Vec<f32> = vec![];
let mut cpu_readings: Vec<f32> = vec![];
loop {
sys.refresh_process(pid);
let proc = sys.process(pid).unwrap();
mem_readings_kb.push(proc.memory() as f32);
mem_readings_bytes.push(proc.memory() as f32);
cpu_readings.push(proc.cpu_usage());
if mem_stop_recv.try_recv().is_ok() {
break;
}
// The file is roughly a minute long so storing memory usage
// every half second is sufficient.
thread::sleep(std::time::Duration::from_millis(500));
}
validate_memory_benchmark(&mem_readings_kb, &cpu_readings);
validate_memory_benchmark(&mem_readings_bytes, &cpu_readings);
});

let recv_state = shared_state.clone();
Expand Down Expand Up @@ -119,7 +122,7 @@ mod mem_bench_impl {
let mem_usage_mean = mems.mean_axis(Axis(0)).unwrap();
let mem_usage_std = mems.std_axis(Axis(0), 0.0);
println!(
"Memory Usage: {:.2}kB ~ +/- {:.2}kB",
"Memory Usage: {:.2}bytes ~ +/- {:.2}bytes",
mem_usage_mean, mem_usage_std
);
let mem_usage_mean = mem_usage_mean.into_owned();
Expand All @@ -131,26 +134,26 @@ mod mem_bench_impl {

let mem_usage_min = mem_usage_mean - mem_usage_std;

let mem_usage_over_amount = mem_usage_max - MAXIMUM_MEM_USAGE_KB;
let mem_usage_threshold = MAXIMUM_MEM_USAGE_KB * DIFF_THRESHOLD;
let worst_case_message = format!("Worst Case Memory Usage:\nThe mean memory usage, {:.2}kB, is added to the stdev, {:.2}kB, equaling {:.2}kB.", mem_usage_mean, mem_usage_std, mem_usage_max);
let worst_case_message = format!("{}\nThen this value is subtracted by the ideal maximum memory usage {:.2}kB equaling {:.2}kB.", worst_case_message, MAXIMUM_MEM_USAGE_KB, mem_usage_over_amount);
let mem_usage_over_amount = mem_usage_max - MAXIMUM_MEM_USAGE_BYTES;
let mem_usage_threshold = MAXIMUM_MEM_USAGE_BYTES * DIFF_THRESHOLD;
let worst_case_message = format!("Worst Case Memory Usage:\nThe mean memory usage, {:.2}bytes, is added to the stdev, {:.2}bytes, equaling {:.2}bytes.", mem_usage_mean, mem_usage_std, mem_usage_max);
let worst_case_message = format!("{}\nThen this value is subtracted by the ideal maximum memory usage {:.2}bytes equaling {:.2}bytes.", worst_case_message, MAXIMUM_MEM_USAGE_BYTES, mem_usage_over_amount);
let worst_case_message = format!(
"{}\nThis amount is greater than {:.2}kB which is {:.2} of the maximum amount {:.2}.",
worst_case_message, mem_usage_threshold, DIFF_THRESHOLD, MAXIMUM_MEM_USAGE_KB
"{}\nThis amount is greater than {:.2}bytes which is {:.2} of the maximum amount {:.2}.",
worst_case_message, mem_usage_threshold, DIFF_THRESHOLD, MAXIMUM_MEM_USAGE_BYTES
);
assert!(
(mem_usage_max - MAXIMUM_MEM_USAGE_KB) <= MAXIMUM_MEM_USAGE_KB * DIFF_THRESHOLD,
(mem_usage_max - MAXIMUM_MEM_USAGE_BYTES) <= MAXIMUM_MEM_USAGE_BYTES * DIFF_THRESHOLD,
"{}",
worst_case_message
);
assert!(*mem_usage_std <= MAXIMUM_MEM_USAGE_KB*MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM,
"Memory Standard Deviation, {:.2}kB, was greater than {:.2}kB which is {:.2} of the maximum memory usage {:.2}kB.", *mem_usage_std, (
MAXIMUM_MEM_USAGE_KB*MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM), MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM, MAXIMUM_MEM_USAGE_KB
assert!(*mem_usage_std <= MAXIMUM_MEM_USAGE_BYTES*MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM,
"Memory Standard Deviation, {:.2}bytes, was greater than {:.2}bytes which is {:.2} of the maximum memory usage {:.2}bytes.", *mem_usage_std, (
MAXIMUM_MEM_USAGE_BYTES*MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM), MAXIMUM_STANDARD_DEV_RATE_OF_MAXIMUM_MEM, MAXIMUM_MEM_USAGE_BYTES
);
assert!(
mem_usage_min >= ABSOLUTE_MINIMUM_MEM_USAGE,
"Best Case Memory Usage: {:.2}kB was less than absolute minimum {:.2}kB.",
"Best Case Memory Usage: {:.2}bytes was less than absolute minimum {:.2}bytes.",
mem_usage_min,
ABSOLUTE_MINIMUM_MEM_USAGE
);
Expand Down

0 comments on commit 39e494a

Please sign in to comment.