From e83f30e97ca604d268c68c281286e35b2aad8e51 Mon Sep 17 00:00:00 2001 From: Luke Dashjr Date: Wed, 8 May 2024 04:07:48 +0000 Subject: [PATCH] Bump default dbfilesize to 128 MiB The default max file size for LevelDB is 2 MiB, which results in the LevelDB compaction code generating ~4 disk cache flushes per second when syncing with the Bitcoin network. These disk cache flushes are triggered by fdatasync() syscall issued by the LevelDB compaction code when reaching the max file size. If the database is on a HDD this flush rate brings the whole system to a crawl. It also results in very slow throughput since 2 MiB * 4 flushes per second is about 8 MiB / second max throughput, while even an old HDD can pull 100 - 200 MiB / second streaming throughput. Increase the default db file size for LevelDB to 128 MiB instead so the flush rate drops to about 1 flush / 2 seconds and the system no longer gets so sluggish. The db file size value chosen also matches the MAX_BLOCKFILE_SIZE file size setting already used by the block storage. --- src/dbwrapper.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/dbwrapper.h b/src/dbwrapper.h index 3a591c2cb2..e3cc9c78cc 100644 --- a/src/dbwrapper.h +++ b/src/dbwrapper.h @@ -23,7 +23,7 @@ static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64; static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024; -static constexpr size_t DEFAULT_DB_FILE_SIZE{2}; +static constexpr size_t DEFAULT_DB_FILE_SIZE{128}; //! User-controlled performance and debug options. struct DBOptions {