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

Use jemalloc for allocation #42

Closed
itamarst opened this issue Jul 8, 2020 · 3 comments · Fixed by #51
Closed

Use jemalloc for allocation #42

itamarst opened this issue Jul 8, 2020 · 3 comments · Fixed by #51
Labels
enhancement New feature or request

Comments

@itamarst
Copy link
Collaborator

itamarst commented Jul 8, 2020

Benefits:

  1. Consistent API across OSes
  2. Might help with More robust fallback malloc() and friends on Linux #33, Make sure via test that we're not leaking memory due to using dynamic linker's malloc() #35
  3. Might reduce memory fragmentation overhead
@itamarst itamarst added the enhancement New feature or request label Jul 8, 2020
@itamarst
Copy link
Collaborator Author

itamarst commented Jul 9, 2020

Looks like it has the necessary symbol mangling: https://github.com/jemalloc/jemalloc/blob/master/INSTALL.md

@itamarst
Copy link
Collaborator Author

itamarst commented Jul 9, 2020

Spent some time talking to jemalloc developers, and reading code:

  1. On macOS, libc code might use its internal malloc(), and then if user code uses public free() and it's jemalloc's free(), segfaults happen. As such, you can't safely use jemalloc as replacement allocator on macOS.
  2. Mangled-namespace jemalloc for Rust wouldn't have this issue, because it'd be for Rust code only, and might provide a speed boost (no need to hit malloc() reentrancy path) and perhaps reduce fragmentation.
  3. On Linux, there might be benefit to use jemalloc to reduce fragmentation and perhaps simplify the code so there's less dlsym() and pre-initialization edge cases.

@itamarst
Copy link
Collaborator Author

My first attempt at item 2 above (jemalloc for Rust) resulted in a deadlock or something, not sure why.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant