Compare commits

...

3 Commits

Author SHA1 Message Date
antoniofilipovic
57f160707e fix bug - hardcoded wrong arena 2024-02-08 10:43:58 +01:00
antoniofilipovic
0e2e12d218 fix gitignore 2024-02-08 09:51:13 +01:00
antoniofilipovic
0db9240089 add patch for jemalloc 2024-02-08 09:32:31 +01:00
4 changed files with 56 additions and 2 deletions

1
libs/.gitignore vendored
View File

@ -7,3 +7,4 @@
!pulsar.patch
!antlr4.10.1.patch
!rocksdb8.1.1.patch
!jemalloc-oversize_threshold.patch

View 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);

View File

@ -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 \

View File

@ -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
}