Skip to content
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

Merged
merged 7 commits into from
May 17, 2023
Merged

Feature/disable wal flag #5702

merged 7 commits into from
May 17, 2023

Conversation

asdacap
Copy link
Contributor

@asdacap asdacap commented May 16, 2023

  • The WAL files in rocksdb is its durability mechanism which allow it to recover writes in crashes where the memtable was not flushed to the disk.
  • In case of snapsync or full pruning, if it crash, it will have to start over meaning the WAL is unnecessary, so disabling it saves some writes. The amount saved should be roughly the size of the DB, which is around 160GB.
  • For full pruning (32GB mem budget), total writes goes down from 1.7TB to 1.5TB. Total time remains at 40minute, probably because SSD warmed up or some other limit.
  • For snap sync (HeavyWrite tune), total writes goes down from 3.28TB to 2.93TB. Took similar amount of time (1 hour vs 50 minute).
  • I guess instead of DisableWAL a better more universal term for flag would be NoDurable, NonDurable, DurabilityNotRequired or something, but can't find a good one. Got idea?

Changes

  • Add DisableWAL write flag. Integrate with RocksDB, SnapSync and FullPruning.
  • Slight change with snap sync, code save where it uses write batch instead.
  • Refactor rocksdb's smoke test to use same test for column and non-column db.
  • Add an explicit flush when full pruning complete.

Types of changes

What types of changes does your code introduce?

  • Optimization
  • Refactoring

Testing

Requires testing

  • Yes
  • No

If yes, did you write tests?

  • Yes
  • No

Notes on testing

Optional. Remove if not applicable.

Remarks

Optional. Remove if not applicable.

@asdacap asdacap marked this pull request as ready for review May 16, 2023 06:44
@@ -182,6 +182,8 @@ protected virtual void RunPruning(IPruningContext pruning, Keccak statRoot)
writeFlags = WriteFlags.None;
}

writeFlags |= WriteFlags.DisableWAL;
Copy link
Member

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 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would do too.

Comment on lines +38 to +41
private WriteOptions? _noWalWrite;
private WriteOptions? _lowPriorityAndNoWalWrite;
private WriteOptions? _lowPriorityWriteOptions;
private ReadOptions? _readAheadReadOptions = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can/should they be static?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, WriteAheadLogSync is from config.

@@ -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)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either save flags to bool and reuse them or check for both flags in one go.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok

@asdacap asdacap merged commit 0169378 into master May 17, 2023
@asdacap asdacap deleted the feature/disable-wal-flag branch May 17, 2023 03:25
@asdacap asdacap mentioned this pull request Jan 2, 2024
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants