Compare commits
3 Commits
master
...
jemalloc-n
Author | SHA1 | Date | |
---|---|---|---|
|
57f160707e | ||
|
0e2e12d218 | ||
|
0db9240089 |
1
libs/.gitignore
vendored
1
libs/.gitignore
vendored
@ -7,3 +7,4 @@
|
||||
!pulsar.patch
|
||||
!antlr4.10.1.patch
|
||||
!rocksdb8.1.1.patch
|
||||
!jemalloc-oversize_threshold.patch
|
||||
|
39
libs/jemalloc-oversize_threshold.patch
Normal file
39
libs/jemalloc-oversize_threshold.patch
Normal file
@ -0,0 +1,39 @@
|
||||
diff --git a/src/ctl.c b/src/ctl.c
|
||||
index 48afaa61..1e545710 100644
|
||||
--- a/src/ctl.c
|
||||
+++ b/src/ctl.c
|
||||
@@ -2376,11 +2376,11 @@ arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
||||
|
||||
malloc_mutex_lock(tsd_tsdn(tsd), &ctl_mtx);
|
||||
MIB_UNSIGNED(arena_ind, 1);
|
||||
- if (arena_ind < narenas_total_get()) {
|
||||
+ if (arena_ind <= narenas_total_get()) {
|
||||
extent_hooks_t *old_extent_hooks;
|
||||
arena = arena_get(tsd_tsdn(tsd), arena_ind, false);
|
||||
if (arena == NULL) {
|
||||
- if (arena_ind >= narenas_auto) {
|
||||
+ if (arena_ind >= narenas_auto+1) {
|
||||
ret = EFAULT;
|
||||
goto label_return;
|
||||
}
|
||||
@@ -2388,6 +2388,20 @@ arena_i_extent_hooks_ctl(tsd_t *tsd, const size_t *mib, size_t miblen,
|
||||
(extent_hooks_t *)&extent_hooks_default;
|
||||
READ(old_extent_hooks, extent_hooks_t *);
|
||||
if (newp != NULL) {
|
||||
+ if (arena_ind == narenas_auto) {
|
||||
+ // init some number for huge arena
|
||||
+ arena_init_huge();
|
||||
+ //init arena really
|
||||
+ arena = arena_choose_huge(tsd);
|
||||
+ extent_hooks_t *new_extent_hooks
|
||||
+ JEMALLOC_CC_SILENCE_INIT(NULL);
|
||||
+ WRITE(new_extent_hooks, extent_hooks_t *);
|
||||
+ old_extent_hooks = extent_hooks_set(tsd, arena,
|
||||
+ new_extent_hooks);
|
||||
+ READ(old_extent_hooks, extent_hooks_t *);
|
||||
+ ret = 0;
|
||||
+ goto label_return;
|
||||
+ }
|
||||
/* Initialize a new arena as a side effect. */
|
||||
extent_hooks_t *new_extent_hooks
|
||||
JEMALLOC_CC_SILENCE_INIT(NULL);
|
@ -265,7 +265,7 @@ repo_clone_try_double "${primary_urls[jemalloc]}" "${secondary_urls[jemalloc]}"
|
||||
|
||||
# this is hack for cmake in libs to set path, and for FindJemalloc to use Jemalloc_INCLUDE_DIR
|
||||
pushd jemalloc
|
||||
|
||||
patch -p1 < ../jemalloc-oversize_threshold.patch
|
||||
./autogen.sh
|
||||
MALLOC_CONF="retain:false,percpu_arena:percpu,oversize_threshold:0,muzzy_decay_ms:5000,dirty_decay_ms:5000" \
|
||||
./configure \
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Copyright 2023 Memgraph Ltd.
|
||||
// Copyright 2024 Memgraph Ltd.
|
||||
//
|
||||
// Use of this software is governed by the Business Source License
|
||||
// included in the file licenses/BSL.txt; by using this file, you agree to be bound by the terms of the Business Source
|
||||
@ -224,6 +224,20 @@ void SetHooks() {
|
||||
LOG_FATAL("Error setting custom hooks for jemalloc arena {}", i);
|
||||
}
|
||||
}
|
||||
auto last_arena = n_arenas;
|
||||
// For oversize arena, no need to read hooks, it will be intialized
|
||||
// with arena, just set our custom hooks
|
||||
std::string func_name = "arena." + std::to_string(last_arena) + ".extent_hooks";
|
||||
|
||||
if (err) {
|
||||
LOG_FATAL("Error setting jemalloc hooks for jemalloc arena {}", last_arena);
|
||||
}
|
||||
|
||||
err = mallctl(func_name.c_str(), nullptr, nullptr, &new_hooks, sizeof(new_hooks));
|
||||
|
||||
if (err) {
|
||||
LOG_FATAL("Error setting custom hooks for jemalloc oversize threshold arena {}", last_arena);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user