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

Add temporary way to configure amount of data prefetched per file handle #1021

Merged
merged 3 commits into from
Sep 18, 2024
Merged
Changes from 1 commit
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
34 changes: 33 additions & 1 deletion mountpoint-s3/src/prefetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ impl Default for PrefetcherConfig {
#[allow(clippy::identity_op)]
fn default() -> Self {
Self {
max_read_window_size: 2 * 1024 * 1024 * 1024,
max_read_window_size: determine_max_read_size(),
sequential_prefetch_multiplier: 8,
read_timeout: Duration::from_secs(60),
// We want these large enough to tolerate a single out-of-order Linux readahead, which
Expand All @@ -176,6 +176,38 @@ impl Default for PrefetcherConfig {
}
}

/// Provide the maximum read size for the prefetcher, for which there is one prefetcher per file handle.
///
/// This allows a way to override the prefetch window rather than using the hardcoded default within Mountpoint.
/// We do not recommend using the override, and it may be removed at any time.
///
/// This unstable override is expected to be removed once adaptive prefetching based on available memory is available:
/// https://github.com/awslabs/mountpoint-s3/issues/987
fn determine_max_read_size() -> usize {
let env_var_key = "UNSTABLE_MOUNTPOINT_MAX_PREFETCH_WINDOW_SIZE";
dannycjones marked this conversation as resolved.
Show resolved Hide resolved
const DEFAULT_READ_WINDOW_SIZE: usize = 2 * 1024 * 1024 * 1024;

match std::env::var_os(env_var_key) {
Some(val) => match val.to_string_lossy().parse() {
Ok(val) => {
dannycjones marked this conversation as resolved.
Show resolved Hide resolved
tracing::warn!(
"successfully overridden prefetch read window size \
with new value {val} bytes from unstable environment config",
);
val
}
Err(_) => {
tracing::warn!(
"{env_var_key} did not contain a valid positive integer \
for prefetch bytes, using {DEFAULT_READ_WINDOW_SIZE} bytes instead",
);
DEFAULT_READ_WINDOW_SIZE
}
},
None => DEFAULT_READ_WINDOW_SIZE,
}
}

/// A [Prefetcher] creates and manages prefetching GetObject requests to objects.
#[derive(Debug)]
pub struct Prefetcher<Stream> {
Expand Down
Loading