Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf: Enable THP by default #21829

Merged
merged 4 commits into from
Mar 19, 2025
Merged

perf: Enable THP by default #21829

merged 4 commits into from
Mar 19, 2025

Conversation

orlp
Copy link
Collaborator

@orlp orlp commented Mar 18, 2025

If a system supports THP (transparent huge pages) but has it set by default to only use it when madvise is called (which is the default on for example Ubuntu server), then we wouldn't use THP before this PR. This PR ensures that jemalloc will madvise every allocation with MADV_HUGEPAGE so that they will be used on such systems.

On PDS-H SF=10 and SF=100 I observed performance increases of 15-20% with the new streaming engine. I expect THP to pretty much always be beneficial for Polars unless we start swapping memory in random access patterns (but arguably when you reach that point you have already lost as an OLAP system).

If for whatever reason you find THP to be a regression, please do let us know, in the meantime you can specify the env variable _RJEM_MALLOC_CONF=thp:never,metadata_thp:never to disable it again.


The PR does contain a bit of a questionable linker hack to hide jemalloc's warnings on systems that don't support THP. I hope this doesn't break any builds.

I've switched to setting the jemalloc flags in Python now, right before importing the Polars library. This was the only way I could think of to disable setting the THP flag for non-linux systems, as that causes jemalloc to print warnings. I failed in trying to silence these warnings.

@github-actions github-actions bot added performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars labels Mar 18, 2025
Copy link

codecov bot commented Mar 19, 2025

Codecov Report

Attention: Patch coverage is 75.00000% with 2 lines in your changes missing coverage. Please review.

Project coverage is 80.94%. Comparing base (6fd6e01) to head (7a3d86d).
Report is 7 commits behind head on main.

Files with missing lines Patch % Lines
py-polars/polars/__init__.py 75.00% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #21829      +/-   ##
==========================================
- Coverage   81.00%   80.94%   -0.06%     
==========================================
  Files        1620     1623       +3     
  Lines      233617   233988     +371     
  Branches     2691     2693       +2     
==========================================
+ Hits       189249   189413     +164     
- Misses      43738    43943     +205     
- Partials      630      632       +2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@orlp orlp merged commit 08b67bf into pola-rs:main Mar 19, 2025
19 checks passed
kdn36 pushed a commit to kdn36/polars that referenced this pull request Mar 19, 2025
jsjasonseba pushed a commit to jsjasonseba/polars that referenced this pull request Mar 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Performance issues or improvements python Related to Python Polars rust Related to Rust Polars
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant