mirror of
https://gitlab.nic.cz/labs/bird.git
synced 2024-12-22 09:41:54 +00:00
Disable multiple malloc arenas
In our usecase, these are impossibly greedy because we often free memory in a different thread than where we allocate, forcing the default allocator to scatter the used memory all over the place.
This commit is contained in:
parent
2d7c8f4d5c
commit
792189e807
@ -371,6 +371,7 @@ esac
|
|||||||
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h stdatomic.h])
|
AC_CHECK_HEADERS_ONCE([alloca.h syslog.h stdatomic.h])
|
||||||
AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAVE_MMAP], [1], [Define to 1 if mmap() is available.])], have_mman=no)
|
AC_CHECK_HEADER([sys/mman.h], [AC_DEFINE([HAVE_MMAP], [1], [Define to 1 if mmap() is available.])], have_mman=no)
|
||||||
AC_CHECK_FUNC([aligned_alloc], [AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if aligned_alloc() is available.])], have_aligned_alloc=no)
|
AC_CHECK_FUNC([aligned_alloc], [AC_DEFINE([HAVE_ALIGNED_ALLOC], [1], [Define to 1 if aligned_alloc() is available.])], have_aligned_alloc=no)
|
||||||
|
AC_CHECK_HEADER([malloc.h], [AC_DEFINE([HAVE_MALLOC_H], [1], [Define to 1 if malloc.h is available.])], have_malloc_h=no)
|
||||||
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
|
AC_CHECK_MEMBERS([struct sockaddr.sa_len], [], [], [#include <sys/socket.h>])
|
||||||
|
|
||||||
if test "$have_aligned_alloc" = "no" && test "$have_mman" = "no" ; then
|
if test "$have_aligned_alloc" = "no" && test "$have_mman" = "no" ; then
|
||||||
|
@ -18,6 +18,10 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#ifdef HAVE_MALLOC_H
|
||||||
|
# include <malloc.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_MMAP
|
#ifdef HAVE_MMAP
|
||||||
# include <sys/mman.h>
|
# include <sys/mman.h>
|
||||||
#endif
|
#endif
|
||||||
@ -501,6 +505,11 @@ page_dump(struct dump_request *dreq)
|
|||||||
void
|
void
|
||||||
resource_sys_init(void)
|
resource_sys_init(void)
|
||||||
{
|
{
|
||||||
|
#ifdef HAVE_MALLOC_H
|
||||||
|
if (!mallopt(M_ARENA_MAX, 1))
|
||||||
|
log(L_WARN "Failed to disable multiple malloc arenas, memory consumption may skyrocket.");
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef CONFIG_DISABLE_THP
|
#ifdef CONFIG_DISABLE_THP
|
||||||
/* Disable transparent huge pages, they do not work properly with madvice(MADV_DONTNEED) */
|
/* Disable transparent huge pages, they do not work properly with madvice(MADV_DONTNEED) */
|
||||||
if (prctl(PR_SET_THP_DISABLE, (unsigned long) 1, (unsigned long) 0, (unsigned long) 0, (unsigned long) 0) < 0)
|
if (prctl(PR_SET_THP_DISABLE, (unsigned long) 1, (unsigned long) 0, (unsigned long) 0, (unsigned long) 0) < 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user