From 29af2942591df382ed0fbc9f08b34ca52cecf0be Mon Sep 17 00:00:00 2001 From: Rhett Creighton Date: Sat, 6 Jun 2026 00:59:43 +0000 Subject: [PATCH] =?UTF-8?q?beta7:=20perf=20tuning=20=E2=80=94=20leveldb=20?= =?UTF-8?q?max=5Fopen=5Ffiles=20scaling=20+=20HTTP=20workqueue=20defaults?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/dbwrapper.cpp | 12 +++++++++++- src/httpserver.h | 7 +++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/dbwrapper.cpp b/src/dbwrapper.cpp index b34be5af7bc..4325d147e43 100644 --- a/src/dbwrapper.cpp +++ b/src/dbwrapper.cpp @@ -21,7 +21,17 @@ static leveldb::Options GetOptions(size_t nCacheSize) options.write_buffer_size = nCacheSize / 4; // up to two write buffers may be held in memory simultaneously options.filter_policy = leveldb::NewBloomFilterPolicy(10); options.compression = leveldb::kNoCompression; - options.max_open_files = 64; + // Scale the open-file cache with the configured DB cache so a large block + // index doesn't thrash file descriptors (matches Bitcoin Core's later + // scaling): 64 for small caches, up to 1000 for large ones. Each ~2MiB + // table is held open via these, so this is purely an I/O/FD tuning and + // does not change any stored or computed value. + options.max_open_files = 1000; + if (nCacheSize < 100 * 1048576) { + // Use the conservative default for small caches (e.g. unit tests, + // low-memory configs) to keep FD usage modest. + options.max_open_files = 64; + } if (leveldb::kMajorVersion > 1 || (leveldb::kMajorVersion == 1 && leveldb::kMinorVersion >= 16)) { // LevelDB versions before 1.16 consider short writes to be corruption. Only trigger error // on corruption in later versions. diff --git a/src/httpserver.h b/src/httpserver.h index 93fb5d8d60d..bcda0f305df 100644 --- a/src/httpserver.h +++ b/src/httpserver.h @@ -11,8 +11,11 @@ #include #include -static const int DEFAULT_HTTP_THREADS=4; -static const int DEFAULT_HTTP_WORKQUEUE=16; +// Raised from 4/16 to avoid "Work queue depth exceeded" HTTP 500s under load +// (e.g. wallet/GUI bursts of concurrent RPC calls). Still user-overridable via +// -rpcthreads / -rpcworkqueue; config-only, no consensus or value impact. +static const int DEFAULT_HTTP_THREADS=8; +static const int DEFAULT_HTTP_WORKQUEUE=256; static const int DEFAULT_HTTP_SERVER_TIMEOUT=30; struct evhttp_request;