mirror of
https://github.com/neovim/neovim
synced 2025-07-18 18:21:46 +00:00
Remove support for using jemalloc instead of the system allocator
There was never any investigation done to determine whether using jemalloc was actually a net benefit for nvim. It has been a portability limitation and adds another factor to consider when triaging issues.
This commit is contained in:
@ -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")
|
message(FATAL_ERROR "Sanitizers are only supported for Clang")
|
||||||
endif()
|
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)
|
if(ENABLE_LIBINTL)
|
||||||
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
|
# LibIntl (not Intl) selects our FindLibIntl.cmake script. #8464
|
||||||
find_package(LibIntl REQUIRED)
|
find_package(LibIntl REQUIRED)
|
||||||
|
@ -68,7 +68,7 @@ To skip bundled (`third-party/*`) dependencies:
|
|||||||
|
|
||||||
1. Install the dependencies using a package manager.
|
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 mpack
|
||||||
sudo luarocks build lpeg
|
sudo luarocks build lpeg
|
||||||
sudo luarocks build inspect
|
sudo luarocks build inspect
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
# - Try to find jemalloc
|
|
||||||
# Once done this will define
|
|
||||||
# JEMALLOC_FOUND - System has jemalloc
|
|
||||||
# JEMALLOC_INCLUDE_DIRS - The jemalloc include directories
|
|
||||||
# JEMALLOC_LIBRARIES - The libraries needed to use jemalloc
|
|
||||||
|
|
||||||
if(NOT USE_BUNDLED_JEMALLOC)
|
|
||||||
find_package(PkgConfig)
|
|
||||||
if (PKG_CONFIG_FOUND)
|
|
||||||
pkg_check_modules(PC_JEMALLOC QUIET jemalloc)
|
|
||||||
endif()
|
|
||||||
else()
|
|
||||||
set(PC_JEMALLOC_INCLUDEDIR)
|
|
||||||
set(PC_JEMALLOC_INCLUDE_DIRS)
|
|
||||||
set(PC_JEMALLOC_LIBDIR)
|
|
||||||
set(PC_JEMALLOC_LIBRARY_DIRS)
|
|
||||||
set(LIMIT_SEARCH NO_DEFAULT_PATH)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
set(JEMALLOC_DEFINITIONS ${PC_JEMALLOC_CFLAGS_OTHER})
|
|
||||||
|
|
||||||
find_path(JEMALLOC_INCLUDE_DIR jemalloc/jemalloc.h
|
|
||||||
PATHS ${PC_JEMALLOC_INCLUDEDIR} ${PC_JEMALLOC_INCLUDE_DIRS}
|
|
||||||
${LIMIT_SEARCH})
|
|
||||||
|
|
||||||
# If we're asked to use static linkage, add libjemalloc.a as a preferred library name.
|
|
||||||
if(JEMALLOC_USE_STATIC)
|
|
||||||
list(APPEND JEMALLOC_NAMES
|
|
||||||
"${CMAKE_STATIC_LIBRARY_PREFIX}jemalloc${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
||||||
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
|
||||||
list(INSERT JEMALLOC_NAMES 0
|
|
||||||
"${CMAKE_STATIC_LIBRARY_PREFIX}jemalloc${CMAKE_STATIC_LIBRARY_SUFFIX}")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
list(APPEND JEMALLOC_NAMES jemalloc)
|
|
||||||
|
|
||||||
find_library(JEMALLOC_LIBRARY NAMES ${JEMALLOC_NAMES}
|
|
||||||
HINTS ${PC_JEMALLOC_LIBDIR} ${PC_JEMALLOC_LIBRARY_DIRS}
|
|
||||||
${LIMIT_SEARCH})
|
|
||||||
|
|
||||||
set(JEMALLOC_LIBRARIES ${JEMALLOC_LIBRARY})
|
|
||||||
set(JEMALLOC_INCLUDE_DIRS ${JEMALLOC_INCLUDE_DIR})
|
|
||||||
|
|
||||||
include(FindPackageHandleStandardArgs)
|
|
||||||
# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE
|
|
||||||
# if all listed variables are TRUE
|
|
||||||
find_package_handle_standard_args(JeMalloc DEFAULT_MSG
|
|
||||||
JEMALLOC_LIBRARY JEMALLOC_INCLUDE_DIR)
|
|
||||||
|
|
||||||
mark_as_advanced(JEMALLOC_INCLUDE_DIR JEMALLOC_LIBRARY)
|
|
@ -47,10 +47,6 @@ if(Iconv_FOUND)
|
|||||||
set(HAVE_ICONV 1)
|
set(HAVE_ICONV 1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(JEMALLOC_FOUND)
|
|
||||||
set(HAVE_JEMALLOC 1)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
check_function_exists(_putenv_s HAVE_PUTENV_S)
|
check_function_exists(_putenv_s HAVE_PUTENV_S)
|
||||||
if(WIN32 AND NOT HAVE_PUTENV_S)
|
if(WIN32 AND NOT HAVE_PUTENV_S)
|
||||||
message(SEND_ERROR "_putenv_s() function not found on your system.")
|
message(SEND_ERROR "_putenv_s() function not found on your system.")
|
||||||
|
@ -62,7 +62,6 @@
|
|||||||
#cmakedefine FEAT_TUI
|
#cmakedefine FEAT_TUI
|
||||||
|
|
||||||
#ifndef UNIT_TESTING
|
#ifndef UNIT_TESTING
|
||||||
#cmakedefine HAVE_JEMALLOC
|
|
||||||
#cmakedefine LOG_LIST_ACTIONS
|
#cmakedefine LOG_LIST_ACTIONS
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -7,10 +7,6 @@
|
|||||||
# These CFLAGS can be used in addition to those specified in CMakeLists.txt:
|
# These CFLAGS can be used in addition to those specified in CMakeLists.txt:
|
||||||
# CMAKE_EXTRA_FLAGS="-DCMAKE_C_FLAGS=-ftrapv -Wlogical-op"
|
# 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:
|
# Sets the build type; defaults to Debug. Valid values:
|
||||||
#
|
#
|
||||||
# - Debug: Disables optimizations (-O0), enables debug information.
|
# - Debug: Disables optimizations (-O0), enables debug information.
|
||||||
@ -36,7 +32,6 @@
|
|||||||
# them.
|
# them.
|
||||||
#
|
#
|
||||||
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_BUSTED=OFF
|
# 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_LIBTERMKEY=OFF
|
||||||
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBUV=OFF
|
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBUV=OFF
|
||||||
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBVTERM=OFF
|
# DEPS_CMAKE_FLAGS += -DUSE_BUNDLED_LIBVTERM=OFF
|
||||||
|
@ -34,32 +34,6 @@ int uv_pipe_open(struct uv_pipe_s *handle, int fd)
|
|||||||
return result;
|
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
|
// Hint Coverity that adding item to d avoids losing track
|
||||||
// of the memory allocated for item.
|
// of the memory allocated for item.
|
||||||
typedef struct {} dictitem_T;
|
typedef struct {} dictitem_T;
|
||||||
|
@ -397,11 +397,6 @@ endif()
|
|||||||
|
|
||||||
set(NVIM_EXEC_LINK_LIBRARIES ${NVIM_LINK_LIBRARIES} ${LUA_PREFERRED_LIBRARIES})
|
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)
|
if(POLICY CMP0069)
|
||||||
cmake_policy(SET CMP0069 NEW)
|
cmake_policy(SET CMP0069 NEW)
|
||||||
endif()
|
endif()
|
||||||
|
@ -18,35 +18,15 @@
|
|||||||
#include "nvim/ui.h"
|
#include "nvim/ui.h"
|
||||||
#include "nvim/api/vim.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
|
#ifdef UNIT_TESTING
|
||||||
# define malloc(size) mem_malloc(size)
|
# define malloc(size) mem_malloc(size)
|
||||||
# define calloc(count, size) mem_calloc(count, size)
|
# define calloc(count, size) mem_calloc(count, size)
|
||||||
# define realloc(ptr, size) mem_realloc(ptr, size)
|
# define realloc(ptr, size) mem_realloc(ptr, size)
|
||||||
# define free(ptr) mem_free(ptr)
|
# 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;
|
MemMalloc mem_malloc = &malloc;
|
||||||
MemFree mem_free = &free;
|
MemFree mem_free = &free;
|
||||||
MemCalloc mem_calloc = &calloc;
|
MemCalloc mem_calloc = &calloc;
|
||||||
MemRealloc mem_realloc = &realloc;
|
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
|
#endif
|
||||||
|
|
||||||
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
#ifdef INCLUDE_GENERATED_DECLARATIONS
|
||||||
|
@ -62,12 +62,6 @@ static char *features[] = {
|
|||||||
"-iconv",
|
"-iconv",
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef HAVE_JEMALLOC
|
|
||||||
"+jemalloc",
|
|
||||||
#else
|
|
||||||
"-jemalloc",
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef FEAT_TUI
|
#ifdef FEAT_TUI
|
||||||
"+tui",
|
"+tui",
|
||||||
#else
|
#else
|
||||||
|
8
third-party/CMakeLists.txt
vendored
8
third-party/CMakeLists.txt
vendored
@ -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 "Use bundled dependencies." ON)
|
||||||
|
|
||||||
option(USE_BUNDLED_GPERF "Use the bundled version of gperf." ${USE_BUNDLED})
|
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_UNIBILIUM "Use the bundled unibilium." ${USE_BUNDLED})
|
||||||
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
option(USE_BUNDLED_LIBTERMKEY "Use the bundled libtermkey." ${USE_BUNDLED})
|
||||||
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
|
option(USE_BUNDLED_LIBVTERM "Use the bundled libvterm." ${USE_BUNDLED})
|
||||||
@ -150,9 +149,6 @@ set(LIBTERMKEY_SHA256 6c0d87c94ab9915e76ecd313baec08dedf3bd56de83743d9aa923a0819
|
|||||||
set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/3f62ac6b7bdffda39d68f723fb1806dfd6d6382d.tar.gz)
|
set(LIBVTERM_URL https://github.com/neovim/libvterm/archive/3f62ac6b7bdffda39d68f723fb1806dfd6d6382d.tar.gz)
|
||||||
set(LIBVTERM_SHA256 1c8b318370f00f831f43e3ec86a48984250e3ee5c76beb106a421c9a42286ac5)
|
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_URL https://github.com/luvit/luv/archive/1.9.1-1.tar.gz)
|
||||||
set(LUV_SHA256 562b9efaad30aa051a40eac9ade0c3df48bb8186763769abe47ec3fb3edb1268)
|
set(LUV_SHA256 562b9efaad30aa051a40eac9ade0c3df48bb8186763769abe47ec3fb3edb1268)
|
||||||
|
|
||||||
@ -212,10 +208,6 @@ if(USE_BUNDLED_LUAROCKS)
|
|||||||
include(BuildLuarocks)
|
include(BuildLuarocks)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(USE_BUNDLED_JEMALLOC)
|
|
||||||
include(BuildJeMalloc)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(USE_BUNDLED_LUV)
|
if(USE_BUNDLED_LUV)
|
||||||
include(BuildLuv)
|
include(BuildLuv)
|
||||||
endif()
|
endif()
|
||||||
|
24
third-party/cmake/BuildJeMalloc.cmake
vendored
24
third-party/cmake/BuildJeMalloc.cmake
vendored
@ -1,24 +0,0 @@
|
|||||||
if(WIN32)
|
|
||||||
message(STATUS "Building jemalloc in Windows is not supported (skipping)")
|
|
||||||
return()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
ExternalProject_Add(jemalloc
|
|
||||||
PREFIX ${DEPS_BUILD_DIR}
|
|
||||||
URL ${JEMALLOC_URL}
|
|
||||||
DOWNLOAD_DIR ${DEPS_DOWNLOAD_DIR}/jemalloc
|
|
||||||
DOWNLOAD_COMMAND ${CMAKE_COMMAND}
|
|
||||||
-DPREFIX=${DEPS_BUILD_DIR}
|
|
||||||
-DDOWNLOAD_DIR=${DEPS_DOWNLOAD_DIR}/jemalloc
|
|
||||||
-DURL=${JEMALLOC_URL}
|
|
||||||
-DEXPECTED_SHA256=${JEMALLOC_SHA256}
|
|
||||||
-DTARGET=jemalloc
|
|
||||||
-DUSE_EXISTING_SRC_DIR=${USE_EXISTING_SRC_DIR}
|
|
||||||
-P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/DownloadAndExtractFile.cmake
|
|
||||||
BUILD_IN_SOURCE 1
|
|
||||||
CONFIGURE_COMMAND ${DEPS_BUILD_DIR}/src/jemalloc/configure
|
|
||||||
CC=${DEPS_C_COMPILER} --prefix=${DEPS_INSTALL_DIR}
|
|
||||||
BUILD_COMMAND ""
|
|
||||||
INSTALL_COMMAND ${MAKE_PRG} install_include install_lib_static)
|
|
||||||
|
|
||||||
list(APPEND THIRD_PARTY_DEPS jemalloc)
|
|
Reference in New Issue
Block a user