Skip to content

Make no_thp disable transparent huge pages again - #178

Open
Darkatse wants to merge 1 commit into
purpleprotocol:masterfrom
Darkatse:no-thp-allow-thp
Open

Darkatse wants to merge 1 commit into
purpleprotocol:masterfrom
Darkatse:no-thp-allow-thp

Conversation

@Darkatse

Copy link
Copy Markdown

Since libmimalloc-sys 0.1.45, the no_thp feature no longer disables transparent huge pages: on a host where THP is always, the process still gets huge pages. mimalloc v2.3.0/v3.3.0 moved the process-wide prctl(PR_SET_THP_DISABLE) from MI_NO_THP to the allow_thp option, whose default comes from MI_DEFAULT_ALLOW_THP (microsoft/mimalloc@67aeaf2); MI_NO_THP now only skips madvise(MADV_HUGEPAGE). This PR defines MI_DEFAULT_ALLOW_THP=0 instead, as MI_NO_THP=ON does in mimalloc's CMake build and as no_thp does in the Rust crate in microsoft/mimalloc.

Unlike libmimalloc-sys 0.1.44 and earlier, no_thp is now a default rather than a hard switch: MIMALLOC_ALLOW_THP=1 turns THP back on, as with the CMake build.

On Debian 13 (kernel 6.12, THP always), a process that touches 512 MiB, for both v3 and v2:

  • libmimalloc-sys 0.1.44: THP_enabled: 0, no huge pages
  • libmimalloc-sys 0.1.49: THP_enabled: 1, more than 500 MiB of huge pages
  • this PR: THP_enabled: 0, no huge pages

The new test in libmimalloc-sys checks PR_GET_THP_DISABLE and fails without the fix for v3 and v2; CI runs it on Linux. The change works unchanged with the mimalloc versions in #169. Only libmimalloc-sys needs a release.

Thank you for maintaining this crate!

mimalloc v2.3.0/v3.3.0 changed `MI_NO_THP` to only skip
`madvise(MADV_HUGEPAGE)`; disabling THP for the process now depends on
the `allow_thp` option, whose default comes from `MI_DEFAULT_ALLOW_THP`.
Define that instead, as `MI_NO_THP=ON` does in mimalloc's CMake build,
and test it on Linux.
Copilot AI balanced review requested due to automatic review settings November 22, 2026 17:12

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota. Try requesting a review at a lower effort level.

An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants