{"record":{"id":"9cd942d4b53856af","repo":"pola-rs/polars","slug":"polars-memory-prefetch-madvise-willneed-is-not-sup","errorCode":null,"errorMessage":"POLARS_MEMORY_PREFETCH=madvise_willneed is not supported by this system","messagePattern":"POLARS_MEMORY_PREFETCH=madvise_willneed is not supported by this system","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/mem.rs","lineNumber":138,"sourceCode":"                #[cfg(target_family = \"unix\")]\n                {\n                    madvise_sequential\n                }\n                #[cfg(not(target_family = \"unix\"))]\n                {\n                    panic!(\n                        \"POLARS_MEMORY_PREFETCH=madvise_sequential is not supported by this system\"\n                    );\n                }\n            },\n            Some(\"madvise_willneed\") => {\n                #[cfg(target_family = \"unix\")]\n                {\n                    madvise_willneed\n                }\n                #[cfg(not(target_family = \"unix\"))]\n                {\n                    panic!(\n                        \"POLARS_MEMORY_PREFETCH=madvise_willneed is not supported by this system\"\n                    );\n                }\n            },\n            Some(\"madvise_populate_read\") => {\n                #[cfg(target_os = \"linux\")]\n                {\n                    madvise_populate_read\n                }\n                #[cfg(not(target_os = \"linux\"))]\n                {\n                    panic!(\n                        \"POLARS_MEMORY_PREFETCH=madvise_populate_read is not supported by this system\"\n                    );\n                }\n            },\n            Some(\"force_populate_read\") => force_populate_read,\n            Some(v) => panic!(\"invalid value for POLARS_MEMORY_PREFETCH: {v}\"),","sourceCodeStart":120,"sourceCodeEnd":156,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/mem.rs#L120-L156","documentation":"Polars panics when POLARS_MEMORY_PREFETCH=madvise_willneed is set on a non-Unix platform. The madvise(2)-based WILLNEED prefetch strategy only exists on Unix systems, so get_memory_prefetch_func aborts at startup rather than silently ignoring the setting. This is a fail-fast configuration validation for an unsupported platform/env combination.","triggerScenarios":"Setting the env var POLARS_MEMORY_PREFETCH=madvise_willneed (e.g. via ~/.bashrc, CI config, or python os.environ) and then calling begin_read / any memory-mapped read (e.g. scanning an IPC/parquet file) on Windows or another non-Unix target.","commonSituations":"Sharing env var exports across OSes; running the same config on Windows/macOS after tuning on Linux; copying a tuned Polars performance config into cross-platform CI.","solutions":["Remove POLARS_MEMORY_PREFETCH=madvise_willneed from the environment on non-Unix systems","Unset the variable just for this process, e.g. env -u POLARS_MEMORY_PREFETCH on Unix or delete it in os.environ before importing polars","Switch the value to a portable option such as prefetch_l2 or no_prefetch","Use madvise_willneed only on Unix: conditionally set the var with sys.platform checks"],"exampleFix":"// before\nos.environ[\"POLARS_MEMORY_PREFETCH\"] = \"madvise_willneed\"\nimport polars as pl\n// after\nif sys.platform != \"win32\":\n    os.environ[\"POLARS_MEMORY_PREFETCH\"] = \"madvise_willneed\"\nimport polars as pl","handlingStrategy":"validation","validationCode":"import os, sys\nif \"POLARS_MEMORY_PREFETCH\" in os.environ and sys.platform == \"win32\":\n    raise RuntimeError(\"POLARS_MEMORY_PREFETCH=madvise_willneed is unsupported on this platform\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Set POLARS_MEMORY_PREFETCH only behind a platform check","Prefer portable values like prefetch_l2 in shared configs","Document env vars per-OS in your deployment setup","Audit environment dumps in cross-platform CI"],"tags":["rust","configuration","environment-variable","platform-specific"],"backgroundTag":"unsupported-platform","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"}