Skip to content

Commit b55708a

Browse files
authored
Optionally disable jemalloc (#973)
### What problem does this PR solve? Enable jemalloc by default. You can disable jemalloc by passing the `-DENABLE_JEMALLOC=OFF` option to CMake. Issue link:#358 ### Type of change - [x] Refactoring
1 parent e8237a0 commit b55708a

File tree

9 files changed

+42
-15
lines changed

9 files changed

+42
-15
lines changed

CMakeLists.txt

+6-1
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,12 @@ ADD_DEFINITIONS(-D INFINITY_DEBUG)
131131

132132
# find_package(Boost REQUIRED)
133133
find_package(Lz4 REQUIRED)
134-
find_package(jemalloc REQUIRED)
134+
135+
# You can disable jemalloc by passing the `-DENABLE_JEMALLOC=OFF` option to CMake.
136+
option(ENABLE_JEMALLOC "Enable jemalloc support" ON)
137+
if(ENABLE_JEMALLOC)
138+
find_package(jemalloc REQUIRED)
139+
endif()
135140

136141
add_subdirectory(src)
137142
add_subdirectory(third_party EXCLUDE_FROM_ALL)

benchmark/csv/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@ add_executable(csv_benchmark
77

88
target_link_libraries(csv_benchmark
99
zsv_parser
10-
jemalloc.a
1110
)
1211

12+
if(ENABLE_JEMALLOC)
13+
target_link_libraries(csv_benchmark jemalloc.a)
14+
endif()
15+
1316
target_include_directories(csv_benchmark
1417
PUBLIC "${CMAKE_SOURCE_DIR}/third_party/zsv/include")
1518
target_include_directories(csv_benchmark

benchmark/embedding/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ target_link_libraries(
99
infinity_core
1010
sql_parser
1111
benchmark_profiler
12-
jemalloc.a
1312
)
1413

1514
add_executable(ann_ivfflat_benchmark
@@ -29,9 +28,13 @@ target_link_libraries(
2928
fastpfor
3029
atomic.a
3130
lz4.a
32-
jemalloc.a
3331
)
3432

33+
if(ENABLE_JEMALLOC)
34+
target_link_libraries(hnsw_benchmark2 jemalloc.a)
35+
target_link_libraries(ann_ivfflat_benchmark jemalloc.a)
36+
endif()
37+
3538
# add_definitions(-march=native)
3639
# add_definitions(-msse4.2 -mfma)
3740
# add_definitions(-mavx2 -mf16c -mpopcnt)

benchmark/fst/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,12 @@ target_link_libraries(
88
fst
99
infinity_core
1010
benchmark_profiler
11-
jemalloc.a
1211
)
1312

13+
if(ENABLE_JEMALLOC)
14+
target_link_libraries(fst jemalloc.a)
15+
endif()
16+
1417
# add_definitions(-march=native)
1518
# add_definitions(-msse4.2 -mfma)
1619
# add_definitions(-mavx2 -mf16c -mpopcnt)

benchmark/local_infinity/CMakeLists.txt

+8-5
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ target_link_libraries(
1515
fastpfor
1616
lz4.a
1717
atomic.a
18-
jemalloc.a
1918
)
2019

2120
# ########################################
@@ -37,7 +36,6 @@ target_link_libraries(
3736
fastpfor
3837
lz4.a
3938
atomic.a
40-
jemalloc.a
4139
)
4240

4341
# query benchmark
@@ -57,7 +55,6 @@ target_link_libraries(
5755
fastpfor
5856
lz4.a
5957
atomic.a
60-
jemalloc.a
6158
)
6259

6360
# ########################################
@@ -79,7 +76,6 @@ target_link_libraries(
7976
fastpfor
8077
lz4.a
8178
atomic.a
82-
jemalloc.a
8379
)
8480

8581
# query benchmark
@@ -99,9 +95,16 @@ target_link_libraries(
9995
fastpfor
10096
lz4.a
10197
atomic.a
102-
jemalloc.a
10398
)
10499

100+
if(ENABLE_JEMALLOC)
101+
target_link_libraries(infinity_benchmark jemalloc.a)
102+
target_link_libraries(knn_import_benchmark jemalloc.a)
103+
target_link_libraries(knn_query_benchmark jemalloc.a)
104+
target_link_libraries(fulltext_import_benchmark jemalloc.a)
105+
target_link_libraries(fulltext_query_benchmark jemalloc.a)
106+
endif()
107+
105108
# add_definitions(-march=native)
106109
# add_definitions(-msse4.2 -mfma)
107110
# add_definitions(-mavx2 -mf16c -mpopcnt)

benchmark/polling_scheduler/CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,8 @@ target_link_libraries(
2222
polling_scheduler_benchmark
2323
infinity_core
2424
benchmark_profiler
25-
jemalloc.a
26-
)
25+
)
26+
27+
if(ENABLE_JEMALLOC)
28+
target_link_libraries(polling_scheduler_benchmark jemalloc.a)
29+
endif()

benchmark/remote_infinity/CMakeLists.txt

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,12 @@ target_link_libraries(
2424
lz4.a
2525
atomic.a
2626
thrift.a
27-
jemalloc.a
2827
)
2928

29+
if(ENABLE_JEMALLOC)
30+
target_link_libraries(remote_query_benchmark jemalloc.a)
31+
endif()
32+
3033
# add_definitions(-march=native)
3134
# add_definitions(-msse4.2 -mfma)
3235
# add_definitions(-mavx2 -mf16c -mpopcnt)

cmake/Findjemalloc.cmake

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ endif()
2828
include(FindPackageHandleStandardArgs)
2929
# handle the QUIETLY and REQUIRED arguments and set JEMALLOC_FOUND to TRUE
3030
# if all listed variables are TRUE and the requested version matches.
31-
find_package_handle_standard_args(Jemalloc REQUIRED_VARS
31+
find_package_handle_standard_args(jemalloc REQUIRED_VARS
3232
JEMALLOC_LIBRARY JEMALLOC_INCLUDE_DIR
3333
VERSION_VAR JEMALLOC_VERSION)
3434

src/CMakeLists.txt

+5-1
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,12 @@ target_link_libraries(infinity
252252
atomic.a
253253
event.a
254254
oatpp.a
255-
jemalloc.a
256255
)
256+
257+
if(ENABLE_JEMALLOC)
258+
target_link_libraries(infinity jemalloc.a)
259+
endif()
260+
257261
target_link_directories(infinity PUBLIC "${CMAKE_BINARY_DIR}/lib")
258262
target_link_directories(infinity PUBLIC "${CMAKE_BINARY_DIR}/third_party/oatpp/src/")
259263

0 commit comments

Comments
 (0)