-
Notifications
You must be signed in to change notification settings - Fork 461
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
Feature/disable wal flag #5702
Feature/disable wal flag #5702
Changes from 6 commits
8f67538
5c5f5fb
3b478f8
74c797f
3f4ab61
679c585
a8d080e
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 |
---|---|---|
|
@@ -35,9 +35,10 @@ public class DbOnTheRocks : IDbWithSpan, ITunableDb | |
|
||
private IntPtr? _rateLimiter; | ||
internal WriteOptions? WriteOptions { get; private set; } | ||
internal WriteOptions? LowPriorityWriteOptions { get; private set; } | ||
|
||
internal ReadOptions? _readAheadReadOptions = null; | ||
private WriteOptions? _noWalWrite; | ||
private WriteOptions? _lowPriorityAndNoWalWrite; | ||
private WriteOptions? _lowPriorityWriteOptions; | ||
private ReadOptions? _readAheadReadOptions = null; | ||
Comment on lines
+38
to
+41
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can/should they be static? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, |
||
|
||
internal DbOptions? DbOptions { get; private set; } | ||
|
||
|
@@ -396,9 +397,18 @@ protected virtual void BuildOptions<T>(PerTableDbConfig dbConfig, Options<T> opt | |
WriteOptions.SetSync(dbConfig | ||
.WriteAheadLogSync); // potential fix for corruption on hard process termination, may cause performance degradation | ||
|
||
LowPriorityWriteOptions = new WriteOptions(); | ||
LowPriorityWriteOptions.SetSync(dbConfig.WriteAheadLogSync); | ||
Native.Instance.rocksdb_writeoptions_set_low_pri(LowPriorityWriteOptions.Handle, true); | ||
_noWalWrite = new WriteOptions(); | ||
_noWalWrite.SetSync(dbConfig.WriteAheadLogSync); | ||
_noWalWrite.DisableWal(1); | ||
|
||
_lowPriorityWriteOptions = new WriteOptions(); | ||
_lowPriorityWriteOptions.SetSync(dbConfig.WriteAheadLogSync); | ||
Native.Instance.rocksdb_writeoptions_set_low_pri(_lowPriorityWriteOptions.Handle, true); | ||
|
||
_lowPriorityAndNoWalWrite = new WriteOptions(); | ||
_lowPriorityAndNoWalWrite.SetSync(dbConfig.WriteAheadLogSync); | ||
_lowPriorityAndNoWalWrite.DisableWal(1); | ||
Native.Instance.rocksdb_writeoptions_set_low_pri(_lowPriorityAndNoWalWrite.Handle, true); | ||
|
||
// When readahead flag is on, the next keys are expected to be after the current key. Increasing this value, | ||
// will increase the chances that the next keys will be in the cache, which reduces iops and latency. This | ||
|
@@ -471,6 +481,11 @@ public byte[]? this[ReadOnlySpan<byte> key] | |
} | ||
|
||
public void Set(ReadOnlySpan<byte> key, byte[]? value, WriteFlags flags = WriteFlags.None) | ||
{ | ||
SetWithColumnFamily(key, null, value, flags); | ||
} | ||
|
||
internal void SetWithColumnFamily(ReadOnlySpan<byte> key, ColumnFamilyHandle? cf, byte[]? value, WriteFlags flags = WriteFlags.None) | ||
{ | ||
if (_isDisposing) | ||
{ | ||
|
@@ -483,11 +498,11 @@ public void Set(ReadOnlySpan<byte> key, byte[]? value, WriteFlags flags = WriteF | |
{ | ||
if (value is null) | ||
{ | ||
_db.Remove(key, null, WriteFlagsToWriteOptions(flags)); | ||
_db.Remove(key, cf, WriteFlagsToWriteOptions(flags)); | ||
} | ||
else | ||
{ | ||
_db.Put(key, value, null, WriteFlagsToWriteOptions(flags)); | ||
_db.Put(key, value, cf, WriteFlagsToWriteOptions(flags)); | ||
} | ||
} | ||
catch (RocksDbSharpException e) | ||
|
@@ -499,9 +514,19 @@ public void Set(ReadOnlySpan<byte> key, byte[]? value, WriteFlags flags = WriteF | |
|
||
public WriteOptions? WriteFlagsToWriteOptions(WriteFlags flags) | ||
{ | ||
if (flags == WriteFlags.LowPriority) | ||
if ((flags & WriteFlags.LowPriority) != 0 && (flags & WriteFlags.DisableWAL) != 0) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Either save flags to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok |
||
{ | ||
return _lowPriorityAndNoWalWrite; | ||
} | ||
|
||
if ((flags & WriteFlags.DisableWAL) != 0) | ||
{ | ||
return _noWalWrite; | ||
} | ||
|
||
if ((flags & WriteFlags.LowPriority) != 0) | ||
{ | ||
return LowPriorityWriteOptions; | ||
return _lowPriorityWriteOptions; | ||
} | ||
|
||
return WriteOptions; | ||
|
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.
Why not start with it and then set
LowPriority
based on_pruningConfig.FullPruningDisableLowPriorityWrites
?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.
That would do too.