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

unpack_ram: More graceful handling of low unpack ram #2780

Merged
merged 1 commit into from
May 29, 2021
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
27 changes: 21 additions & 6 deletions src/dist/component/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,23 @@ fn unpack_ram(
.ok()
.and_then(|budget_str| budget_str.parse::<usize>().ok())
{
// Note: In future we may want to add a warning or even an override if a user
// supplied budget is larger than effective_max_ram.
Some(budget) => budget,
Some(budget) => {
if budget < minimum_ram {
warn!(
"Ignoring RUSTUP_UNPACK_RAM ({}) less than minimum of {}.",
budget, minimum_ram
);
minimum_ram
} else if budget > default_max_unpack_ram {
warn!(
"Ignoring RUSTUP_UNPACK_RAM ({}) greater than detected available RAM of {}.",
budget, default_max_unpack_ram
);
default_max_unpack_ram
} else {
budget
}
}
kinnison marked this conversation as resolved.
Show resolved Hide resolved
None => {
if let Some(h) = notify_handler {
h(Notification::SetDefaultBufferSize(default_max_unpack_ram))
Expand All @@ -193,10 +207,11 @@ fn unpack_ram(
}
};

if io_chunk_size > unpack_ram {
panic!("RUSTUP_UNPACK_RAM must be larger than {}", io_chunk_size);
if minimum_ram > unpack_ram {
panic!("RUSTUP_UNPACK_RAM must be larger than {}", minimum_ram);
} else {
unpack_ram
}
unpack_ram
}

/// Handle the async result of io operations
Expand Down