Skip to content

Commit

Permalink
Use RandomAccess for better caching
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Mar 14, 2024
1 parent c2ad82a commit 946af08
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,9 @@ private NodeState(string fileName, MemoryAllocator<byte> allocator, bool integri
// reopen handle in asynchronous mode
handle.Dispose();

const FileOptions dontSkipBuffer = FileOptions.Asynchronous | FileOptions.SequentialScan;
const FileOptions skipBuffer = FileOptions.Asynchronous | FileOptions.WriteThrough | FileOptions.SequentialScan;
// FileOptions.RandomAccess to keep the whole file cached in the page cache
const FileOptions dontSkipBuffer = FileOptions.Asynchronous | FileOptions.RandomAccess;
const FileOptions skipBuffer = FileOptions.Asynchronous | FileOptions.WriteThrough | FileOptions.RandomAccess;
handle = File.OpenHandle(fileName, FileMode.Open, FileAccess.ReadWrite, FileShare.Read, writeThrough ? skipBuffer : dontSkipBuffer);

// restore state
Expand Down

0 comments on commit 946af08

Please sign in to comment.