pola-rs/polars · error
POLARS_MEMORY_PREFETCH=madvise_populate_read is not…
Error message
POLARS_MEMORY_PREFETCH=madvise_populate_read is not supported by this system
What it means
Polars panics when POLARS_MEMORY_PREFETCH=madvise_populate_read is set on a platform other than Linux. MADV_POPULATE_READ is a Linux-only madvise(2) flag, so get_memory_prefetch_func fails fast instead of silently degrading. Thrown at memory-mapped read setup (begin_read).
Solutions
- Remove or unset POLARS_MEMORY_PREFETCH=madvise_populate_read on non-Linux systems
- Use a cross-platform value like prefetch_l2 or no_prefetch
- Guard the env var with a Linux check (sys.platform == 'linux') before setting it
- If populate semantics are needed, verify the target is Linux; otherwise fall back to madvise_willneed on Unix
Example fix
// before
os.environ["POLARS_MEMORY_PREFETCH"] = "madvise_populate_read"
// after
if sys.platform.startswith("linux"):
os.environ["POLARS_MEMORY_PREFETCH"] = "madvise_populate_read" Defensive patterns
Strategy: validation
Validate before calling
import os, sys
if os.environ.get("POLARS_MEMORY_PREFETCH") == "madvise_populate_read" and not sys.platform.startswith("linux"):
os.environ.pop("POLARS_MEMORY_PREFETCH", None) Prevention
- Use madvise_populate_read only on Linux
- Guard tuning env vars with sys.platform checks
- Keep Linux-only tuning in Linux-only profiles/container images
- Test cross-platform CI with the same env config to catch leaks
When it happens
Trigger: POLARS_MEMORY_PREFETCH=madvise_populate_read exported in the environment, then performing a mapped read on macOS, Windows, or another non-Linux Unix platform.
Common situations: macOS developers copying a Linux-tuned env config; Docker-on-macOS where the var leaks to the host toolchain; cross-platform CI matrices.
Understand the failure class
Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.
Related errors
- integer
- invalid value for POLARS_MEMORY_PREFETCH
- invalid value for POLARS_NDJSON_CHUNK_SIZE
- invalid value for POLARS_ROW_GROUP_PREFETCH_KBYTES_BUDGET
- invalid value for POLARS_ROW_GROUP_PREFETCH_SIZE
AI-assisted analysis of pola-rs/polars@fe841f959e (2026-09-18).
Data as JSON: /api/errors/0265119c105d2bf7.
Report an issue: GitHub.
Appendix: source
Thrown at crates/polars-utils/src/mem.rs:150
#[cfg(target_family = "unix")]
{
madvise_willneed
}
#[cfg(not(target_family = "unix"))]
{
panic!(
"POLARS_MEMORY_PREFETCH=madvise_willneed is not supported by this system"
);
}
},
Some("madvise_populate_read") => {
#[cfg(target_os = "linux")]
{
madvise_populate_read
}
#[cfg(not(target_os = "linux"))]
{
panic!(
"POLARS_MEMORY_PREFETCH=madvise_populate_read is not supported by this system"
);
}
},
Some("force_populate_read") => force_populate_read,
Some(v) => panic!("invalid value for POLARS_MEMORY_PREFETCH: {v}"),
};
if verbose {
let func_name = match memory_prefetch_func as usize {
v if v == no_prefetch as *const () as usize => "no_prefetch",
v if v == prefetch_l2 as *const () as usize => "prefetch_l2",
v if v == madvise_sequential as *const () as usize => "madvise_sequential",
v if v == madvise_willneed as *const () as usize => "madvise_willneed",
v if v == madvise_populate_read as *const () as usize => "madvise_populate_read",
v if v == force_populate_read as *const () as usize => "force_populate_read",
_ => unreachable!(),
};View on GitHub (pinned to fe841f959e)