Repository navigation
Conversation
Opt-in flag asking the OS not to retain the database file's pages in its own page cache, so the only in-memory copy is DryDB's page cache — for deployments where page cache is charged to the process (containers, consoles) and the DryDB cache is sized to hold the working set. Best effort: implemented on macOS via fcntl(F_NOCACHE); a no-op elsewhere and for non-file streams. fcntl is variadic and the Apple arm64 ABI passes variadic arguments on the stack, so a naive 3-parameter P/Invoke would hand the callee garbage. The import declares eight fixed integer parameters after cmd so the ninth lands in the outgoing stack area where the callee's va_list starts on arm64 (x86-64 reads the first duplicate register instead); a test round-trips FD_CLOEXEC through F_SETFD/F_GETFD to prove the argument survives the call on the running platform. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an opt-in
DatabaseLoadOptions.BypassOsPageCachethat asks the OS not to retain the database file's pages in its own page cache, so the only in-memory copy of the data is DryDB's page cache (no double caching).fcntl(F_NOCACHE); a documented no-op on other platforms and for non-file streams / custom loaders. (Linux equivalents —O_DIRECTneeds aligned reads that the variable-length page format doesn't provide,posix_fadvise(DONTNEED)needs per-read calls — are left for later.)The interesting part:
fcntlis variadic, and the Apple arm64 ABI passes variadic arguments on the stack, so the naiveDllImport int fcntl(int, int, int)hands the callee garbage (it "works" only by luck of nonzero stack bytes). The import here declares eight fixed integer parameters aftercmdso the ninth lands exactly where the callee'sva_liststarts on arm64, while x86-64's System V convention picks up the first duplicated register slot — passing the value in every slot satisfies both. A test proves the argument survives the call by round-trippingFD_CLOEXECthroughF_SETFD/F_GETFD.All 88 tests pass (85 existing + ABI round-trip, F_NOCACHE success, and an end-to-end read with the flag enabled).
🤖 Generated with Claude Code