{"record":{"id":"0265119c105d2bf7","repo":"pola-rs/polars","slug":"polars-memory-prefetch-madvise-populate-read-is-no","errorCode":null,"errorMessage":"POLARS_MEMORY_PREFETCH=madvise_populate_read is not supported by this system","messagePattern":"POLARS_MEMORY_PREFETCH=madvise_populate_read is not supported by this system","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/mem.rs","lineNumber":150,"sourceCode":"                #[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}\"),\n        };\n\n        if verbose {\n            let func_name = match memory_prefetch_func as usize {\n                v if v == no_prefetch as *const () as usize => \"no_prefetch\",\n                v if v == prefetch_l2 as *const () as usize => \"prefetch_l2\",\n                v if v == madvise_sequential as *const () as usize => \"madvise_sequential\",\n                v if v == madvise_willneed as *const () as usize => \"madvise_willneed\",\n                v if v == madvise_populate_read as *const () as usize => \"madvise_populate_read\",\n                v if v == force_populate_read as *const () as usize => \"force_populate_read\",\n                _ => unreachable!(),\n            };","sourceCodeStart":132,"sourceCodeEnd":168,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/mem.rs#L132-L168","documentation":"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).","triggerScenarios":"POLARS_MEMORY_PREFETCH=madvise_populate_read exported in the environment, then performing a mapped read on macOS, Windows, or another non-Linux Unix platform.","commonSituations":"macOS developers copying a Linux-tuned env config; Docker-on-macOS where the var leaks to the host toolchain; cross-platform CI matrices.","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"],"exampleFix":"// before\nos.environ[\"POLARS_MEMORY_PREFETCH\"] = \"madvise_populate_read\"\n// after\nif sys.platform.startswith(\"linux\"):\n    os.environ[\"POLARS_MEMORY_PREFETCH\"] = \"madvise_populate_read\"","handlingStrategy":"validation","validationCode":"import os, sys\nif os.environ.get(\"POLARS_MEMORY_PREFETCH\") == \"madvise_populate_read\" and not sys.platform.startswith(\"linux\"):\n    os.environ.pop(\"POLARS_MEMORY_PREFETCH\", None)","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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"],"tags":["rust","configuration","environment-variable","linux-only"],"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"}