-
Notifications
You must be signed in to change notification settings - Fork 666
fix(db): reuse ReadOptions in ColumnDbSnapshot to reduce GC pressure #10894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
97fe652
d53729b
99f0cb3
570a9bb
4c697c3
9518077
60acfff
6ded7eb
863e66d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -22,22 +22,36 @@ public class RocksDbReader : ISortedKeyValueStore | |||||||
| private readonly DbOnTheRocks.IteratorManager? _iteratorManager; | ||||||||
| private readonly ColumnFamilyHandle? _columnFamily; | ||||||||
|
|
||||||||
| readonly ReadOptions _options; | ||||||||
| readonly ReadOptions _hintCacheMissOptions; | ||||||||
| private readonly ReadOptions _options; | ||||||||
| private readonly ReadOptions _hintCacheMissOptions; | ||||||||
|
|
||||||||
| public RocksDbReader(DbOnTheRocks mainDb, | ||||||||
| Func<ReadOptions> readOptionsFactory, | ||||||||
| DbOnTheRocks.IteratorManager? iteratorManager = null, | ||||||||
| ColumnFamilyHandle? columnFamily = null) | ||||||||
| : this(mainDb, readOptionsFactory(), readOptionsFactory(), readOptionsFactory, iteratorManager, columnFamily) | ||||||||
| { | ||||||||
| _hintCacheMissOptions.SetFillCache(false); | ||||||||
| } | ||||||||
|
|
||||||||
| /// <summary> | ||||||||
| /// Constructor that accepts pre-created <see cref="ReadOptions"/> instead of a factory. | ||||||||
| /// Used by <see cref="ColumnsDb{T}.ColumnDbSnapshot"/> to share a single pair of ReadOptions | ||||||||
| /// across all column readers, avoiding per-reader native handle allocation and finalizer pressure. | ||||||||
| /// </summary> | ||||||||
| public RocksDbReader(DbOnTheRocks mainDb, | ||||||||
| ReadOptions options, | ||||||||
| ReadOptions hintCacheMissOptions, | ||||||||
| Func<ReadOptions> readOptionsFactory, | ||||||||
| DbOnTheRocks.IteratorManager? iteratorManager = null, | ||||||||
| ColumnFamilyHandle? columnFamily = null) | ||||||||
LukaszRozmej marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
| { | ||||||||
| _mainDb = mainDb; | ||||||||
| _readOptionsFactory = readOptionsFactory; | ||||||||
| _iteratorManager = iteratorManager; | ||||||||
| _columnFamily = columnFamily; | ||||||||
|
|
||||||||
| _options = readOptionsFactory(); | ||||||||
| _hintCacheMissOptions = readOptionsFactory(); | ||||||||
| _hintCacheMissOptions.SetFillCache(false); | ||||||||
| _options = options; | ||||||||
| _hintCacheMissOptions = hintCacheMissOptions; | ||||||||
|
||||||||
| _hintCacheMissOptions = hintCacheMissOptions; | |
| _hintCacheMissOptions = hintCacheMissOptions; | |
| _hintCacheMissOptions.SetFillCache(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The comment above
EnumToIntsays “Non-boxing enum-to-int conversion”, but theConvert.ToInt32(value)fallback will box for most non-(byte/short/int)-sized enum underlying types due to overload resolution in generics. Consider tightening the comment (or adding explicitlong/uint/ushortunsafe branches if truly aiming for non-boxing).