Skip to content

jemalloc "extension" for Linux #4971

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

Merged
merged 114 commits into from
Nov 6, 2022
Merged

jemalloc "extension" for Linux #4971

merged 114 commits into from
Nov 6, 2022

Conversation

lnkuiper
Copy link
Contributor

This PR adds the jemalloc "extension", that we will for 64-bit Linux builds. The default allocator on Linux creates memory fragmentation, which eventually causes allocations to fail (see #3969). jemalloc should do a better job at this. We do not use jemalloc as a global allocator, only our Allocator class calls into jemalloc.

I've put "extension" between quotation marks, because jemalloc can only be loaded statically (no INSTALL/LOAD possible). We've chosen to do this because switching between allocators dynamically causes a bunch of issues with blocks that are allocated while the switch happens.

This was much more work than expected, because I've converted jemalloc to C++, and wrapped it in a namespace to prevent conflicts. jemalloc also has a bunch of platform-specific optimizations, which I had to rip out to make it portable.

Somehow this has caused a regression in TPC-DS q72 in my CI runs, which I cannot reproduce locally. Not sure what is going on there.

Happy to receive any feedback!

P.S.: jemalloc works on macos too, but not (yet) on windows, but we will probably not include it on macos since the default allocator is OK

@lnkuiper
Copy link
Contributor Author

lnkuiper commented Nov 1, 2022

Same issue after changing to your approach. Seems like intptr_max == int64_max despite being 32bit? Or I am misunderstanding something.

Might need to switch to the env variable approach

@Mytherin
Copy link
Collaborator

Mytherin commented Nov 1, 2022

It could be that the crash is happening in the jemalloc start-up code or so, which might still break even if none of the code is actually used as long as it is compiled in. Perhaps excluding the code entirely is a better idea indeed

@lnkuiper
Copy link
Contributor Author

lnkuiper commented Nov 6, 2022

All green! @Mytherin

@Mytherin Mytherin merged commit a09de46 into duckdb:master Nov 6, 2022
@Mytherin
Copy link
Collaborator

Mytherin commented Nov 6, 2022

Awesome! Thanks for all the hard work :)

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.

4 participants