pola-rs/polars · error
in-flight byte budget init must be larger than the…
Error message
in-flight byte budget init must be larger than the target_chunk_size
What it means
After computing the init in-flight byte budget (from POLARS_INFLIGHT_INIT_BYTE_BUDGET or its default), Polars validates that it is at least as large as the target chunk size used for cloud range reads. If the configured budget is smaller than one chunk, ramp-up cannot issue a single full request, so the library panics. This catches contradictory sizing configurations.
Solutions
- Raise POLARS_INFLIGHT_INIT_BYTE_BUDGET to at least the target chunk size (e.g. >= 67108864 when chunk size is 64 MiB).
- Alternatively lower POLARS_DOWNLOAD_CHUNK_SIZE so it does not exceed the init budget.
- Unset POLARS_INFLIGHT_INIT_BYTE_BUDGET to let Polars derive a budget that is always chunk-compatible (default is n/8*target_chunk_size, min 4 chunks).
- If both variables are set programmatically, compute budget = max(budget, chunk_size) before export.
Example fix
// before export POLARS_INFLIGHT_INIT_BYTE_BUDGET=1048576 // after export POLARS_INFLIGHT_INIT_BYTE_BUDGET=67108864 # >= POLARS_DOWNLOAD_CHUNK_SIZE
Defensive patterns
Strategy: validation
Validate before calling
const budget = process.env.POLARS_INFLIGHT_INIT_BYTE_BUDGET;
const chunk = Number(process.env.POLARS_DOWNLOAD_CHUNK_SIZE ?? 67108864);
if (budget !== undefined && Number(budget) < chunk) {
throw new Error(`POLARS_INFLIGHT_INIT_BYTE_BUDGET (${budget}) must be >= target chunk size (${chunk})`);
} Prevention
- Keep POLARS_INFLIGHT_INIT_BYTE_BUDGET >= POLARS_DOWNLOAD_CHUNK_SIZE whenever both are set.
- Prefer setting only the chunk size and letting the init budget be derived.
- Centralize cloud-tuning env vars in one script that enforces cross-variable constraints.
When it happens
Trigger: Setting POLARS_INFLIGHT_INIT_BYTE_BUDGET to a positive integer smaller than the effective target_chunk_size — e.g. budget=1024 while POLARS_DOWNLOAD_CHUNK_SIZE defaults to 64 MiB or is set to a larger value.
Common situations: Tuning the byte budget down for memory-constrained containers without also lowering the download chunk size; combining a small init budget with a large custom chunk size; copying tuning snippets from different blog posts that assumed different chunk sizes.
Understand the failure class
Background: "Invalid value" and "allowed values are" config errors: what your library rejected and how to fix it — this error's family across 41 libraries.
Related errors
- integer
- invalid value for POLARS_INFLIGHT_FLOOR_REQUEST_BUDGET
- invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET
- invalid value for POLARS_INFLIGHT_REQUEST_BUDGET
- invalid value for
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/d1d06d8332b0c5e9.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-io/src/cloud/concurrency/mod.rs:122
let init_byte_budget = std::env::var("POLARS_INFLIGHT_INIT_BYTE_BUDGET")
.map(|x| {
x.parse::<NonZeroU64>()
.unwrap_or_else(|_| {
panic!("invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET: {x}")
})
.get()
})
.unwrap_or_else(|_| {
// This should be lower than the expected BDP so it can ramp-up, but
// too low a value delays the transition to stable.
// Heuristic: higher bandwidth is expected on larger instances.
let n = polars_config::config().max_threads() as u64;
n.div_ceil(8).max(4) * target_chunk_size
})
.max(1);
if init_byte_budget < target_chunk_size {
panic!("in-flight byte budget init must be larger than the target_chunk_size");
}
init_byte_budget
}
/// Maximum number of requests concurrently in flight.
pub fn get_request_budget() -> u64 {
// Since object_store/reqwest use HTTP/1 with a connection pool, this value controls the
// max concurrent TCP sessions to S3 for the pipeline.
// When modifying this value, consider the max_thread count configuration(s), the OS limitations
// (e.g., ulimit -n), and any cloud infrastructure limitations.
std::env::var("POLARS_INFLIGHT_REQUEST_BUDGET")
.map(|x| {
x.parse::<NonZeroU64>()
.unwrap_or_else(|_| panic!("invalid value for POLARS_INFLIGHT_REQUEST_BUDGET: {x}"))
.get()
})
.unwrap_or(512)View on GitHub (pinned to fe841f959e)