Skip to content

Commit

Permalink
dbwrapper: Bump max file size to 128 MiB
Browse files Browse the repository at this point in the history
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 max 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 max file size value chosen also matches the MAX_BLOCKFILE_SIZE file
size setting already used by the block storage.
  • Loading branch information
maciejsszmigiero committed May 4, 2024
1 parent eb0bdbd commit 7f15e71
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/dbwrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ static leveldb::Options GetOptions(size_t nCacheSize)
// on corruption in later versions.
options.paranoid_checks = true;
}
options.max_file_size = 128 << 20;
SetMaxOpenFiles(&options);
return options;
}
Expand Down

0 comments on commit 7f15e71

Please sign in to comment.