Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 willmadvise
every allocation withMADV_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.