-
Notifications
You must be signed in to change notification settings - Fork 252
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Warn when most of the RAM has been used up by Rerun (#1651)
* Warn when most of the RAM has been used up by Rerun Unless the `--memory-limit` is already set, we now warn and suggest setting it when Rerun is using 75% of all available RAM by itself. * On web, always purge memory after 3.5 GB * typos fix * fix clppy
- Loading branch information
Showing
7 changed files
with
102 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/// Amount of available RAM on this machine. | ||
#[cfg(not(target_arch = "wasm32"))] | ||
pub fn total_ram_in_bytes() -> u64 { | ||
use sysinfo::SystemExt as _; | ||
|
||
let mut sys = sysinfo::System::new_all(); | ||
sys.refresh_all(); | ||
|
||
let total_memory = sys.total_memory(); | ||
|
||
re_log::debug!( | ||
"Total RAM: {}", | ||
re_format::format_bytes(sys.total_memory() as _) | ||
); | ||
|
||
total_memory | ||
} | ||
|
||
/// Amount of available RAM on this machine. | ||
#[cfg(target_arch = "wasm32")] | ||
pub fn total_ram_in_bytes() -> u64 { | ||
1_u64 << 32 | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
pub struct RamLimitWarner { | ||
total_ram_in_bytes: u64, | ||
limit: u64, | ||
has_warned: bool, | ||
} | ||
|
||
impl RamLimitWarner { | ||
pub fn warn_at_fraction_of_max(fraction: f32) -> Self { | ||
let total_ram_in_bytes = total_ram_in_bytes(); | ||
let limit = (fraction as f64 * total_ram_in_bytes as f64).round() as _; | ||
Self { | ||
total_ram_in_bytes, | ||
limit, | ||
has_warned: false, | ||
} | ||
} | ||
|
||
/// Warns if we have exceeded the limit. | ||
pub fn update(&mut self) { | ||
if !self.has_warned { | ||
let used = crate::MemoryUse::capture(); | ||
let used = used.counted.or(used.resident); | ||
if let Some(used) = used { | ||
if 0 <= used && self.limit <= used as u64 { | ||
self.has_warned = true; | ||
re_log::warn!( | ||
"RAM usage is {} (with a total of {} system RAM). You may want to start Rerun with the --memory-limit flag to limit RAM usage.", | ||
re_format::format_bytes(used as _), | ||
re_format::format_bytes(self.total_ram_in_bytes as _), | ||
); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9aaf909
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust Benchmark
datastore/insert/batch/rects/insert
548688
ns/iter (± 7436
)563454
ns/iter (± 4845
)0.97
datastore/latest_at/batch/rects/query
1807
ns/iter (± 16
)1857
ns/iter (± 48
)0.97
datastore/latest_at/missing_components/primary
282
ns/iter (± 3
)287
ns/iter (± 1
)0.98
datastore/latest_at/missing_components/secondaries
439
ns/iter (± 6
)437
ns/iter (± 2
)1.00
datastore/range/batch/rects/query
146855
ns/iter (± 1931
)149290
ns/iter (± 1139
)0.98
mono_points_arrow/generate_message_bundles
46132975
ns/iter (± 1443112
)43609337
ns/iter (± 885437
)1.06
mono_points_arrow/generate_messages
132702640
ns/iter (± 1609242
)124759779
ns/iter (± 1189980
)1.06
mono_points_arrow/encode_log_msg
162860909
ns/iter (± 1079071
)153567144
ns/iter (± 711968
)1.06
mono_points_arrow/encode_total
345313535
ns/iter (± 2123134
)327263578
ns/iter (± 1352920
)1.06
mono_points_arrow/decode_log_msg
179544658
ns/iter (± 2553683
)174877558
ns/iter (± 860106
)1.03
mono_points_arrow/decode_message_bundles
69382529
ns/iter (± 1167959
)63007452
ns/iter (± 929547
)1.10
mono_points_arrow/decode_total
247364764
ns/iter (± 3315660
)235272471
ns/iter (± 1431107
)1.05
batch_points_arrow/generate_message_bundles
325291
ns/iter (± 4644
)337269
ns/iter (± 769
)0.96
batch_points_arrow/generate_messages
6090
ns/iter (± 90
)6406
ns/iter (± 15
)0.95
batch_points_arrow/encode_log_msg
359632
ns/iter (± 3756
)369890
ns/iter (± 979
)0.97
batch_points_arrow/encode_total
712768
ns/iter (± 8325
)727174
ns/iter (± 2359
)0.98
batch_points_arrow/decode_log_msg
341582
ns/iter (± 3051
)349355
ns/iter (± 875
)0.98
batch_points_arrow/decode_message_bundles
1995
ns/iter (± 29
)2129
ns/iter (± 11
)0.94
batch_points_arrow/decode_total
349094
ns/iter (± 3911
)355917
ns/iter (± 714
)0.98
arrow_mono_points/insert
6878657573
ns/iter (± 26567516
)6151564119
ns/iter (± 12179130
)1.12
arrow_mono_points/query
1719835
ns/iter (± 21660
)1766371
ns/iter (± 11900
)0.97
arrow_batch_points/insert
2583408
ns/iter (± 27076
)2662872
ns/iter (± 25356
)0.97
arrow_batch_points/query
15791
ns/iter (± 223
)16144
ns/iter (± 116
)0.98
arrow_batch_vecs/insert
41536
ns/iter (± 538
)42411
ns/iter (± 317
)0.98
arrow_batch_vecs/query
376999
ns/iter (± 5739
)387146
ns/iter (± 3875
)0.97
tuid/Tuid::random
33
ns/iter (± 0
)34
ns/iter (± 0
)0.97
This comment was automatically generated by workflow using github-action-benchmark.