-
Notifications
You must be signed in to change notification settings - Fork 34
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
Add support for jemalloc #6
base: 8.1
Are you sure you want to change the base?
Conversation
It's not needed to use C99 compilation but jemalloc #includes <stdbool.h>.
builtin_functions.c uses non-standard dlmallinfo() or mallinfo(). These utility functions are not implemented by jemalloc. Instead it provides malloc_stats_print() and mallctl().
Just add conditional include. Depends on configure.in.
When configure.in sees --enable-jemalloc it does following: 1. adds -ljemalloc to LIBS and 2. adds USE_JEMALLOC C preprocessor define. 3. adds HAVE_JEMALLOC_JEMALLOC_H C preprocessor definition if the library is present during autoconfigure. 4. Removes #include <malloc.h>.
Don't do fancy plumbering with missing mallinfo if USE_JEMALLOC is defined.
This has been sitting uncommented since forever. Minireview in case you still want this in:
I don't see why it couldn't be added at least for a while so it would be easier to benchmark between allocators, but the commit should be as minimal as possible. |
Regarding both comments about src/modules/HTTPLoop/requestobject.c and src/bultin.cmod: both changes are needed here because the code clashes with <stdbool.h>. It's funny that jemalloc includes <stdbool.h> even if it doesn't need C99 flavor to compile. In <stdbool.h> there's In src/builtin.cmod the What I'm more worried about is that the commit is too small. There are places where memory is allocated outside of |
jemalloc handles threaded allocations better than the default glibc's ptmalloc2, but it's less relevant for Pike. Smaller memory fragmentation is more tangible.
You need jemalloc library available on your OS to be able to compile Pike with jemalloc. Build it with
make CONFIGUREARGS="--enable-jemalloc"
.The only externally visible change is in
_memory_usage()
function which depends on malloc's implementation-specific details. glibc's malloc providesstruct mallinfo mallinfo()
, while jemalloc providesint mallctl(const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen);
wherename
argument starts with"stats."
(seeman jemalloc
).