{"record":{"id":"b5fc7b911836135e","repo":"pola-rs/polars","slug":"invalid-value-for-polars-memory-prefetch-v","errorCode":null,"errorMessage":"invalid value for POLARS_MEMORY_PREFETCH: {v}","messagePattern":"invalid value for POLARS_MEMORY_PREFETCH: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/polars-utils/src/mem.rs","lineNumber":156,"sourceCode":"                    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            };\n\n            eprintln!(\"memory prefetch function: {func_name}\");\n        }\n\n        memory_prefetch_func\n    }","sourceCodeStart":138,"sourceCodeEnd":174,"githubUrl":"https://github.com/pola-rs/polars/blob/fe841f959ef4d2ceefc05a310d33ed7b1ab24e5e/crates/polars-utils/src/mem.rs#L138-L174","documentation":"Polars panics with 'invalid value for POLARS_MEMORY_PREFETCH: {v}' when the env var holds an unrecognized string. get_memory_prefetch_func matches against a fixed set of strategy names (no_prefetch, prefetch_l2, madvise_willneed, madvise_populate_read, force_populate_read) and rejects anything else at startup.","triggerScenarios":"POLARS_MEMORY_PREFETCH set to a typo'd or unknown value (e.g. 'willneed', 'prefetch', 'MADVISE_WILLNEED', empty-but-set string) before any memory-mapped read via begin_read.","commonSituations":"Typo in shell profile; case-sensitivity mistakes; stale values from an older Polars version whose accepted names changed; copy-paste from a different library's tuning guide.","solutions":["Set POLARS_MEMORY_PREFETCH to one of: no_prefetch, prefetch_l2, madvise_willneed (Unix), madvise_populate_read (Linux), force_populate_read","Unset the variable entirely to use the default strategy","Check spelling and lowercase casing exactly as documented","echo/print the value early in the process to confirm what is actually set"],"exampleFix":"// before\nos.environ[\"POLARS_MEMORY_PREFETCH\"] = \"MADVISE_WILLNEED\"  # wrong case\n// after\nos.environ[\"POLARS_MEMORY_PREFETCH\"] = \"madvise_willneed\"","handlingStrategy":"validation","validationCode":"VALID = {\"no_prefetch\",\"prefetch_l2\",\"madvise_willneed\",\"madvise_populate_read\",\"force_populate_read\"}\nv = os.environ.get(\"POLARS_MEMORY_PREFETCH\")\nif v is not None and v not in VALID:\n    raise ValueError(f\"POLARS_MEMORY_PREFETCH must be one of {sorted(VALID)}, got {v!r}\")","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Copy accepted values exactly from the documentation (lowercase)","Default to unsetting the var if unsure","Centralize tuning env vars in one validated settings module","Re-validate accepted values after upgrading polars"],"tags":["rust","configuration","environment-variable","invalid-value"],"backgroundTag":"invalid-env-var-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"}