{"record":{"id":"d1d06d8332b0c5e9","repo":"pola-rs/polars","slug":"in-flight-byte-budget-init-must-be-larger-than-the","errorCode":null,"errorMessage":"in-flight byte budget init must be larger than the target_chunk_size","messagePattern":"in-flight byte budget init must be larger than the target_chunk_size","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-io/src/cloud/concurrency/mod.rs","lineNumber":122,"sourceCode":"    let init_byte_budget = std::env::var(\"POLARS_INFLIGHT_INIT_BYTE_BUDGET\")\n        .map(|x| {\n            x.parse::<NonZeroU64>()\n                .unwrap_or_else(|_| {\n                    panic!(\"invalid value for POLARS_INFLIGHT_INIT_BYTE_BUDGET: {x}\")\n                })\n                .get()\n        })\n        .unwrap_or_else(|_| {\n            // This should be lower than the expected BDP so it can ramp-up, but\n            // too low a value delays the transition to stable.\n            // Heuristic: higher bandwidth is expected on larger instances.\n            let n = polars_config::config().max_threads() as u64;\n            n.div_ceil(8).max(4) * target_chunk_size\n        })\n        .max(1);\n\n    if init_byte_budget < target_chunk_size {\n        panic!(\"in-flight byte budget init must be larger than the target_chunk_size\");\n    }\n\n    init_byte_budget\n}\n\n/// Maximum number of requests concurrently in flight.\npub fn get_request_budget() -> u64 {\n    // Since object_store/reqwest use HTTP/1 with a connection pool, this value controls the\n    // max concurrent TCP sessions to S3 for the pipeline.\n    // When modifying this value, consider the max_thread count configuration(s), the OS limitations\n    // (e.g., ulimit -n), and any cloud infrastructure limitations.\n    std::env::var(\"POLARS_INFLIGHT_REQUEST_BUDGET\")\n        .map(|x| {\n            x.parse::<NonZeroU64>()\n                .unwrap_or_else(|_| panic!(\"invalid value for POLARS_INFLIGHT_REQUEST_BUDGET: {x}\"))\n                .get()\n        })\n        .unwrap_or(512)","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-io/src/cloud/concurrency/mod.rs#L104-L140","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nexport POLARS_INFLIGHT_INIT_BYTE_BUDGET=1048576\n// after\nexport POLARS_INFLIGHT_INIT_BYTE_BUDGET=67108864  # >= POLARS_DOWNLOAD_CHUNK_SIZE","handlingStrategy":"validation","validationCode":"const budget = process.env.POLARS_INFLIGHT_INIT_BYTE_BUDGET;\nconst chunk = Number(process.env.POLARS_DOWNLOAD_CHUNK_SIZE ?? 67108864);\nif (budget !== undefined && Number(budget) < chunk) {\n  throw new Error(`POLARS_INFLIGHT_INIT_BYTE_BUDGET (${budget}) must be >= target chunk size (${chunk})`);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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."],"tags":["rust","env-var","configuration","panic","cloud-io"],"backgroundTag":"invalid-config-value","analyzedSha":"fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e","analyzedAt":"2026-09-18T22:14:11.667Z","contentChangedAt":"2026-09-18T22:14:11.667Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}