summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 16:33:49 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2022-02-09 16:33:49 +0000
commit5f96af6e4995a7a38445f3d24482baaedeec0668 (patch)
treeac379c6f64797387285cb8e819ccc2fc6bab6033
parent3df91301de5e6eb415174a6e5cd0786b8927ba47 (diff)
Let default limit be 1G, and add extra comment about usage and non-usage.
-rw-r--r--staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp2
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp3
-rw-r--r--staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.h5
-rw-r--r--vespamalloc/src/vespamalloc/malloc/threadpool.hpp2
4 files changed, 7 insertions, 5 deletions
diff --git a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
index 0fb2dfdda4b..348e9bbd503 100644
--- a/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
+++ b/staging_vespalib/src/tests/shutdownguard/shutdownguard_test.cpp
@@ -40,4 +40,4 @@ TEST("test malloc mmap guard") {
MallocMmapGuard guard(0x100000);
}
-TEST_MAIN() { TEST_RUN_ALL(); } \ No newline at end of file
+TEST_MAIN() { TEST_RUN_ALL(); }
diff --git a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
index 2b932981823..0ced160fda2 100644
--- a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
+++ b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.cpp
@@ -1,5 +1,6 @@
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "malloc_mmap_guard.h"
+#include <vespa/vespalib/util/size_literals.h>
#include <malloc.h>
#include <limits>
#include <cassert>
@@ -16,7 +17,7 @@ MallocMmapGuard::MallocMmapGuard(size_t mmapLimit) :
MallocMmapGuard::~MallocMmapGuard()
{
assert(_threadId == std::this_thread::get_id());
- mallopt(M_MMAP_THRESHOLD, -1);
+ mallopt(M_MMAP_THRESHOLD, 1_Gi);
}
}
diff --git a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.h b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.h
index 3cf26202f9b..03e6d38c03c 100644
--- a/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.h
+++ b/staging_vespalib/src/vespa/vespalib/util/malloc_mmap_guard.h
@@ -7,7 +7,9 @@ namespace vespalib {
/**
* Provides a hint to malloc implementation that all allocations in the scope of this guard
- * will use mmap directly for allocation larger than the givem limit.
+ * will use mmap directly for allocation larger than the given limit.
+ * NB !! Note that guards can not be nested. Intention is to use around third party libraries where
+ * you do not control allocation yourself.
* The effect is implementation dependent. vespamalloc applies this only for the calling thread.
**/
class MallocMmapGuard
@@ -24,4 +26,3 @@ private:
};
} // namespace vespalib
-
diff --git a/vespamalloc/src/vespamalloc/malloc/threadpool.hpp b/vespamalloc/src/vespamalloc/malloc/threadpool.hpp
index a3691a496dd..e9b9fabebdc 100644
--- a/vespamalloc/src/vespamalloc/malloc/threadpool.hpp
+++ b/vespamalloc/src/vespamalloc/malloc/threadpool.hpp
@@ -86,7 +86,7 @@ mallocHelper(size_t exactSize,
template <typename MemBlockPtrT, typename ThreadStatT >
ThreadPoolT<MemBlockPtrT, ThreadStatT>::ThreadPoolT() :
_allocPool(nullptr),
- _mmapLimit(-1),
+ _mmapLimit(0x40000000),
_threadId(0),
_osThreadId(0)
{