Bump RocksDb version and enable autoClose on opt types to prevent memory leaks (#2427)
* Bump RocksDb version and enable autoClose on opt types to prevent memory leaks.
This commit is contained in:
parent
3d3831dde8
commit
e163b69261
|
@ -45,7 +45,7 @@ proc toRocksDb*(
|
||||||
# data model itself has settled down as their optimal values will depend
|
# data model itself has settled down as their optimal values will depend
|
||||||
# on the shape of the data - it'll also be different per column family..
|
# on the shape of the data - it'll also be different per column family..
|
||||||
|
|
||||||
let tableOpts = defaultTableOptions()
|
let tableOpts = defaultTableOptions(autoClose = true)
|
||||||
# This bloom filter helps avoid having to read multiple SST files when looking
|
# This bloom filter helps avoid having to read multiple SST files when looking
|
||||||
# for a value.
|
# for a value.
|
||||||
# A 9.9-bits-per-key ribbon filter takes ~7 bits per key and has a 1% false
|
# A 9.9-bits-per-key ribbon filter takes ~7 bits per key and has a 1% false
|
||||||
|
@ -57,7 +57,7 @@ proc toRocksDb*(
|
||||||
|
|
||||||
if opts.blockCacheSize > 0:
|
if opts.blockCacheSize > 0:
|
||||||
# Share a single block cache instance between all column families
|
# Share a single block cache instance between all column families
|
||||||
tableOpts.blockCache = cacheCreateLRU(opts.blockCacheSize)
|
tableOpts.blockCache = cacheCreateLRU(opts.blockCacheSize, autoClose = true)
|
||||||
|
|
||||||
# Single-level indices might cause long stalls due to their large size -
|
# Single-level indices might cause long stalls due to their large size -
|
||||||
# two-level indexing allows the first level to be kept in memory at all times
|
# two-level indexing allows the first level to be kept in memory at all times
|
||||||
|
@ -75,7 +75,7 @@ proc toRocksDb*(
|
||||||
tableOpts.dataBlockIndexType = DataBlockIndexType.binarySearchAndHash
|
tableOpts.dataBlockIndexType = DataBlockIndexType.binarySearchAndHash
|
||||||
tableOpts.dataBlockHashRatio = 0.75
|
tableOpts.dataBlockHashRatio = 0.75
|
||||||
|
|
||||||
let cfOpts = defaultColFamilyOptions()
|
let cfOpts = defaultColFamilyOptions(autoClose = true)
|
||||||
|
|
||||||
cfOpts.blockBasedTableFactory = tableOpts
|
cfOpts.blockBasedTableFactory = tableOpts
|
||||||
|
|
||||||
|
@ -117,7 +117,7 @@ proc toRocksDb*(
|
||||||
cfOpts.targetFileSizeBase = cfOpts.writeBufferSize div 4
|
cfOpts.targetFileSizeBase = cfOpts.writeBufferSize div 4
|
||||||
cfOpts.targetFileSizeMultiplier = 4
|
cfOpts.targetFileSizeMultiplier = 4
|
||||||
|
|
||||||
let dbOpts = defaultDbOptions()
|
let dbOpts = defaultDbOptions(autoClose = true)
|
||||||
dbOpts.maxOpenFiles = opts.maxOpenFiles
|
dbOpts.maxOpenFiles = opts.maxOpenFiles
|
||||||
|
|
||||||
if opts.rowCacheSize > 0:
|
if opts.rowCacheSize > 0:
|
||||||
|
@ -125,7 +125,7 @@ proc toRocksDb*(
|
||||||
# using range queries, we should probably give more attention to the block
|
# using range queries, we should probably give more attention to the block
|
||||||
# cache
|
# cache
|
||||||
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/options.h#L1276
|
# https://github.com/facebook/rocksdb/blob/af50823069818fc127438e39fef91d2486d6e76c/include/rocksdb/options.h#L1276
|
||||||
dbOpts.rowCache = cacheCreateLRU(opts.rowCacheSize)
|
dbOpts.rowCache = cacheCreateLRU(opts.rowCacheSize, autoClose = true)
|
||||||
|
|
||||||
# Without this option, WAL files might never get removed since a small column
|
# 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
|
# family (like the admin CF) with only tiny writes might keep it open - this
|
||||||
|
|
|
@ -83,10 +83,8 @@ proc init*(
|
||||||
except OSError, IOError:
|
except OSError, IOError:
|
||||||
return err("RocksStoreRef: cannot create database directory")
|
return err("RocksStoreRef: cannot create database directory")
|
||||||
|
|
||||||
let dbOpts = defaultDbOptions()
|
let db = ? openRocksDb(dataDir, columnFamilies = namespaces.mapIt(
|
||||||
|
initColFamilyDescriptor(it, defaultColFamilyOptions(autoClose = true))))
|
||||||
let db = ? openRocksDb(dataDir, dbOpts,
|
|
||||||
columnFamilies = namespaces.mapIt(initColFamilyDescriptor(it)))
|
|
||||||
ok(T(db: db))
|
ok(T(db: db))
|
||||||
|
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ee15ce027b27d5b44b8e2bd3b3d6227568ec0803
|
Subproject commit 01ced36404cf3667742dd68f8bdd6b73f5affa50
|
Loading…
Reference in New Issue