fix `max_total_wal_size` which should be set on the DB (#2363)

This commit is contained in:
Jacek Sieka 2024-06-16 04:11:30 +02:00 committed by GitHub
parent 70805d0346
commit af34f90fe4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 29 deletions

View File

@ -38,19 +38,6 @@ proc getInitOptions(
if opts.writeBufferSize > 0:
cfOpts.setWriteBufferSize(opts.writeBufferSize)
# Without this option, the WAL might never get flushed since a small column
# family (like the admin CF) with only tiny writes might keep it open - this
# negatively affects startup times since the WAL is replayed on every startup.
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/options.h#L719
# Flushing the oldest
let writeBufferSize =
if opts.writeBufferSize > 0:
opts.writeBufferSize
else:
64 * 1024 * 1024 # TODO read from rocksdb?
cfOpts.setMaxTotalWalSize(2 * writeBufferSize)
# When data is written to rocksdb, it is first put in an in-memory table
# whose index is a skip list. Since the mem table holds the most recent data,
# all reads must go through this skiplist which results in slow lookups for
@ -89,6 +76,18 @@ proc getInitOptions(
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/advanced_options.h#L696
dbOpts.setOptimizeFiltersForHits(true)
# Without this option, WAL files might never get removed since a small column
# family (like the admin CF) with only tiny writes might keep it open - this
# negatively affects startup times since the WAL is replayed on every startup.
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/options.h#L719
# Flushing the oldest
let writeBufferSize =
if opts.writeBufferSize > 0:
opts.writeBufferSize
else:
64 * 1024 * 1024 # TODO read from rocksdb?
dbOpts.setMaxTotalWalSize(2 * writeBufferSize)
let tableOpts = defaultTableOptions()
# This bloom filter helps avoid having to read multiple SST files when looking

View File

@ -38,19 +38,6 @@ proc getCFInitOptions(opts: DbOptions): ColFamilyOptionsRef =
if opts.writeBufferSize > 0:
cfOpts.setWriteBufferSize(opts.writeBufferSize)
# Without this option, the WAL might never get flushed since a small column
# family (like the admin CF) with only tiny writes might keep it open - this
# negatively affects startup times since the WAL is replayed on every startup.
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/options.h#L719
# Flushing the oldest
let writeBufferSize =
if opts.writeBufferSize > 0:
opts.writeBufferSize
else:
64 * 1024 * 1024 # TODO read from rocksdb?
cfOpts.setMaxTotalWalSize(2 * writeBufferSize)
# When data is written to rocksdb, it is first put in an in-memory table
# whose index is a skip list. Since the mem table holds the most recent data,
# all reads must go through this skiplist which results in slow lookups for
@ -111,7 +98,7 @@ proc init*(
# Expand argument `opts` to rocksdb options
let (cfOpts, dbOpts) = (opts.getCFInitOptions, opts.getDbInitOptions)
# Column familiy names to allocate when opening the database.
let cfs = KvtCFs.mapIt(($it).initColFamilyDescriptor cfOpts)
@ -146,7 +133,7 @@ proc init*(
rdb.store[n] = oCfs[n.ord]
ok()
proc destroy*(rdb: var RdbInst; eradicate: bool) =
## Destructor (no need to do anything if piggybacked)

2
vendor/nim-rocksdb vendored

@ -1 +1 @@
Subproject commit c5bbf831145d7dd4d60420d69ce9eb601ccd5be2
Subproject commit 293dc0745ea8386237546acb352a265a4bc874b5