Skip to content
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ lsp-server = { version = "0.10.0" }
lsp-types = { package = "gen-lsp-types", version = "0.11.0", features = ["url"] }
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"] }

@chirizxc chirizxc Aug 7, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Windows guarantees a minimum of 64 TLS indices per process, and modern versions of Windows can have up to 1,088.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

microsoft/mimalloc#1359

Maybe we shouldn't enable this feature, since it's random

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer not to enable it, unless benchmark differences are significant. If they are, we should then probably dig a little deeper on when it's okay to enable this optimization

natord = { version = "1.0.9" }
notify = { version = "8.0.0" }
ordermap = { version = "1.0.0" }
Expand Down
Loading