Skip to content

Commit

Permalink
Merge pull request neovim#9526 from jamessan/remove-jemalloc
Browse files Browse the repository at this point in the history
Remove support for using jemalloc instead of the system allocator
  • Loading branch information
jamessan authored Jan 20, 2019
2 parents 62254d2 + c234318 commit 7e3300f
Show file tree
Hide file tree
Showing 12 changed files with 1 addition and 166 deletions.
16 changes: 0 additions & 16 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -456,22 +456,6 @@ if((CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN) AND NOT CMAKE_C_COMPILER_ID MA
message(FATAL_ERROR "Sanitizers are only supported for Clang")
endif()

if(CMAKE_SYSTEM_NAME MATCHES "OpenBSD|FreeBSD|Windows") # see #5318
message(STATUS "skipping jemalloc on this system: ${CMAKE_SYSTEM_NAME}")
option(ENABLE_JEMALLOC "enable jemalloc" OFF)
else()
option(ENABLE_JEMALLOC "enable jemalloc" ON)
endif()

if(ENABLE_JEMALLOC)
if(CLANG_ASAN_UBSAN OR CLANG_MSAN OR CLANG_TSAN)
message(STATUS "Sanitizers enabled; disabling jemalloc")
else()
find_package(JeMalloc REQUIRED)
include_directories(SYSTEM ${JEMALLOC_INCLUDE_DIRS})
endif()
endif()

if(ENABLE_LIBINTL)
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
find_package(LibIntl REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ To skip bundled (`third-party/*`) dependencies:

1. Install the dependencies using a package manager.
```
sudo apt install gperf luajit luarocks libuv1-dev libluajit-5.1-dev libunibilium-dev libmsgpack-dev libtermkey-dev libvterm-dev libjemalloc-dev
sudo apt install gperf luajit luarocks libuv1-dev libluajit-5.1-dev libunibilium-dev libmsgpack-dev libtermkey-dev libvterm-dev
sudo luarocks build mpack
sudo luarocks build lpeg
sudo luarocks build inspect
Expand Down
50 changes: 0 additions & 50 deletions cmake/FindJeMalloc.cmake

This file was deleted.

4 changes: 0 additions & 4 deletions config/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ if(Iconv_FOUND)
set(HAVE_ICONV 1)
endif()

if(JEMALLOC_FOUND)
set(HAVE_JEMALLOC 1)
endif()

check_function_exists(_putenv_s HAVE_PUTENV_S)
if(WIN32 AND NOT HAVE_PUTENV_S)
message(SEND_ERROR "_putenv_s() function not found on your system.")
Expand Down
1 change: 0 additions & 1 deletion config/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,6 @@
#cmakedefine FEAT_TUI

#ifndef UNIT_TESTING
#cmakedefine HAVE_JEMALLOC
#cmakedefine LOG_LIST_ACTIONS
#endif

Expand Down
5 changes: 0 additions & 5 deletions contrib/local.mk.example
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@
# These CFLAGS can be used in addition to those specified in CMakeLists.txt:
# CMAKE_EXTRA_FLAGS="-DCMAKE_C_FLAGS=-ftrapv -Wlogical-op"

# By default, the jemalloc family of memory allocation functions are used.
# Uncomment the following to instead use libc memory allocation functions.
# CMAKE_EXTRA_FLAGS += -DENABLE_JEMALLOC=OFF

# Sets the build type; defaults to Debug. Valid values:
#
# - Debug: Disables optimizations (-O0), enables debug information.
Expand All @@ -36,7 +32,6 @@
# them.
#
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_BUSTED=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_JEMALLOC=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBTERMKEY=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBUV=OFF
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBVTERM=OFF
Expand Down
26 changes: 0 additions & 26 deletions src/coverity-model.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,32 +34,6 @@ int uv_pipe_open(struct uv_pipe_s *handle, int fd)
return result;
}

// Issue 2422
//
// Teach coverity about jemalloc functions, so that it understands
// they are equivalent to malloc ones.

void *je_malloc(size_t size)
{
return __coverity_alloc__(size);
}

void je_free(void *ptr)
{
__coverity_free__(ptr);
}

void *je_calloc(size_t count, size_t size)
{
return je_malloc(count * size);
}

void *je_realloc(void *ptr, size_t size)
{
je_free(ptr);
return je_malloc(size);
}

// Hint Coverity that adding item to d avoids losing track
// of the memory allocated for item.
typedef struct {} dictitem_T;
Expand Down
5 changes: 0 additions & 5 deletions src/nvim/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,6 @@ endif()

set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES})

# Don't use jemalloc in the unit test library.
if(JEMALLOC_FOUND)
list(APPEND NVIM_EXEC_LINK_LIBRARIES ${JEMALLOC_LIBRARIES})
endif()

if(POLICY CMP0069)
cmake_policy(SET CMP0069 NEW)
endif()
Expand Down
20 changes: 0 additions & 20 deletions src/nvim/memory.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,15 @@
#include "nvim/ui.h"
#include "nvim/api/vim.h"

#ifdef HAVE_JEMALLOC
// Force je_ prefix on jemalloc functions.
# define JEMALLOC_NO_DEMANGLE
# include <jemalloc/jemalloc.h>
#endif

#ifdef UNIT_TESTING
# define malloc(size) mem_malloc(size)
# define calloc(count, size) mem_calloc(count, size)
# define realloc(ptr, size) mem_realloc(ptr, size)
# define free(ptr) mem_free(ptr)
# ifdef HAVE_JEMALLOC
MemMalloc mem_malloc = &je_malloc;
MemFree mem_free = &je_free;
MemCalloc mem_calloc = &je_calloc;
MemRealloc mem_realloc = &je_realloc;
# else
MemMalloc mem_malloc = &malloc;
MemFree mem_free = &free;
MemCalloc mem_calloc = &calloc;
MemRealloc mem_realloc = &realloc;
# endif
#else
# ifdef HAVE_JEMALLOC
# define malloc(size) je_malloc(size)
# define calloc(count, size) je_calloc(count, size)
# define realloc(ptr, size) je_realloc(ptr, size)
# define free(ptr) je_free(ptr)
# endif
#endif

#ifdef INCLUDE_GENERATED_DECLARATIONS
Expand Down
6 changes: 0 additions & 6 deletions src/nvim/version.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,6 @@ static char *features[] = {
"-iconv",
#endif

#ifdef HAVE_JEMALLOC
"+jemalloc",
#else
"-jemalloc",
#endif

#ifdef FEAT_TUI
"+tui",
#else
Expand Down
8 changes: 0 additions & 8 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ set(DEPS_DOWNLOAD_DIR "${DEPS_BUILD_DIR}/downloads" CACHE PATH "Dependencies dow
option(USE_BUNDLED "Use bundled dependencies." ON)

option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ${USE_BUNDLED})
option(USE_BUNDLED_JEMALLOC "Use the bundled jemalloc." ${USE_BUNDLED})
option(USE_BUNDLED_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
Expand Down Expand Up @@ -150,9 +149,6 @@ set(LIBTERMKEY_SHA256 6c0d87c94ab9915e76ecd313baec08dedf3bd56de83743d9aa923a0819
set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/3f62ac6b7bdffda39d68f723fb1806dfd6d6382d.tar.gz)
set(LIBVTERM_SHA256 1c8b318370f00f831f43e3ec86a48984250e3ee5c76beb106a421c9a42286ac5)

set(JEMALLOC_URL https://github.com/jemalloc/jemalloc/releases/download/4.5.0/jemalloc-4.5.0.tar.bz2)
set(JEMALLOC_SHA256 9409d85664b4f135b77518b0b118c549009dc10f6cba14557d170476611f6780)

set(LUV_URL https://github.com/luvit/luv/archive/1.9.1-1.tar.gz)
set(LUV_SHA256 562b9efaad30aa051a40eac9ade0c3df48bb8186763769abe47ec3fb3edb1268)

Expand Down Expand Up @@ -212,10 +208,6 @@ if(USE_BUNDLED_LUAROCKS)
include(BuildLuarocks)
endif()

if(USE_BUNDLED_JEMALLOC)
include(BuildJeMalloc)
endif()

if(USE_BUNDLED_LUV)
include(BuildLuv)
endif()
Expand Down
24 changes: 0 additions & 24 deletions third-party/cmake/BuildJeMalloc.cmake

This file was deleted.

0 comments on commit 7e3300f

Please sign in to comment.