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

fix(rust): don't return NaN as free memory fraction #13860

Merged
merged 2 commits into from
Jan 22, 2024
Merged
Changes from all commits
Commits
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
5 changes: 3 additions & 2 deletions crates/polars-pipe/src/executors/sinks/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,9 @@ impl MemTracker {
}

pub(super) fn free_memory_fraction_since_start(&self) -> f64 {
// we divide first to reduce the precision loss in floats
let available_at_start = (self.available_at_start / TO_MB) as f64;
// We divide first to reduce the precision loss in floats.
// We also add 1.0 to available_at_start to prevent division by zero.
let available_at_start = (self.available_at_start / TO_MB) as f64 + 1.0;
let available = (self.get_available() / TO_MB) as f64;
available / available_at_start
}
Expand Down
Loading