Update mimalloc version to 0.1.52 - #27586
Conversation
Updated mimalloc version from 0.1.49 to 0.1.52 with v3 features.
Updated mimalloc feature from 'v3' to 'win_direct_tls'.
| matchit = { version = "0.9.0" } | ||
| memchr = { version = "2.7.1" } | ||
| mimalloc = { version = "0.1.49", features = ["v2"] } | ||
| mimalloc = { version = "0.1.52", features = ["win_direct_tls"] } |
There was a problem hiding this comment.
win_direct_tls enable MI_WIN_DIRECT_TLS
MI_WIN_DIRECT_TLS - Use only direct TLS slots on Windows to avoid extra tests in the malloc fast path (only works if the program uses less than 64 TlsAlloc'd slots in total)
There was a problem hiding this comment.
Can you say more about the motivation for enabling this option and why you think it's correct? I'm not familiar with TLS but codex tells me that the number of TLS can be environment specific, meaning, it can be out of Ruff's control.
There was a problem hiding this comment.
mimalloc makes only two calls to TlsAlloc(): _mi_theap_default_slot and _mi_theap_cached_slot, however, what matters here isn't the calls themselves, but which indices have already been occupied by the process prior to mimalloc
In other words, mimalloc calls must fall within the range 0..63.
The first 64 slots are fast because they are physically embedded directly into the TEB (Thread Environment Block) structure at a fixed offset, and accessing them requires only a single read instruction via a segment register (gs/fs), without any additional pointer dereferencing.
There was a problem hiding this comment.
Maybe we shouldn't enable this feature, since it's random
|
|
Do you have access to a windows machine? It would be great to run some benchmarks to verify that v3 is an improvement. I'm interested in walltime and peak RSS, ideally measured for lint and format across multiple ecosystem projects. I'm asking because I'm very confused about mimalloc's versioning. v2 is stable and v3 is recommended. I've no idea what this is supposed to mean 😆 |
v2 - Uses thread-local segments to reduce memory fragmentation; architecture is frozen and only receives bug/security fixes — minimal change surface, maximum behavioral predictabilit v3 - Simplified lock-free design with improved memory sharing across threads; can reduce memory usage on certain large workloads; supports fully first-class heaps (allocation from any thread, not just the creating one) and more efficient heap-walking, useful for e.g. CPython's GC Source: https://github.com/microsoft/mimalloc/tree/dev3#versions |



close #24880
Seems crash fixed in 0.1.51