From 415ecee603827376e013c920ba7a4cd5422f8f11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C5=91rinc?= Date: Fri, 4 Apr 2025 13:55:28 +0200 Subject: [PATCH] Increase maximum read-only mmap()s used from 1000 to 4096 on 64-bit systems By default LevelDB will only mmap() up to 1000 ldb files for reading and then fall back to using file desciptors. The typical linux system has a 'vm.max_map_count = 65530', so mapping only 1000 files seems arbitarily small. Increase this value to another arbitrarily small value, 4096. Original change by Clem Taylor. Ported to LevelDB 1.22 by Wladimir J. van der Laan. --- util/env_posix.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/util/env_posix.cc b/util/env_posix.cc index c2490322e..003e602a8 100644 --- a/util/env_posix.cc +++ b/util/env_posix.cc @@ -43,8 +43,8 @@ namespace { // Set by EnvPosixTestHelper::SetReadOnlyMMapLimit() and MaxOpenFiles(). int g_open_read_only_file_limit = -1; -// Up to 1000 mmap regions for 64-bit binaries; none for 32-bit. -constexpr const int kDefaultMmapLimit = (sizeof(void*) >= 8) ? 1000 : 0; +// Up to 4096 mmap regions for 64-bit binaries; none for 32-bit. +constexpr const int kDefaultMmapLimit = (sizeof(void*) >= 8) ? 4096 : 0; // Can be set using EnvPosixTestHelper::SetReadOnlyMMapLimit(). int g_mmap_limit = kDefaultMmapLimit;