You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
• Switch PTable verification to the pooled FileStream path on all platforms for simpler, faster IO.
• Remove the custom UnbufferedFileStream/native direct-IO implementation and related
solution/project wiring.
• Update disk IO tests to drop file cache via posix_fadvise (Unix) and read via RandomAccess.
➖ Hard to make portable and testable across OS/filesystems; easy to regress.
➖ This PR’s measurements indicate it was slower in the primary usage (PTable open).
2. Use platform APIs directly in the one call site (Windows FILE_FLAG_NO_BUFFERING)
➕ Keeps direct-IO experimentation localized to PTable verification only.
➕ Avoids carrying a full native-IO abstraction project.
➖ Still requires careful alignment/size rules and complex error handling.
➖ Ends up reintroducing the complexity this PR removes, for uncertain benefit.
Recommendation: Proceed with this PR’s approach: always use the pooled FileStream work item for PTable verification and delete the bespoke unbuffered stream/native project. The direct-IO implementation is complex and low-leverage (single caller), and the simplified path both improves performance in the measured scenario and reduces correctness risk from unsafe/interop code.
Files changed (9) +39 / -50
Refactor (3) +3 / -19
PTable.csAlways use pooled stream for PTable hash verification+3/-17
Always use pooled stream for PTable hash verification
• Removes the Windows-only UnbufferedFileStream branch and uses the existing pooled WorkItem FileStream path universally. Simplifies cleanup by always returning the work item to the pool.
ProcessStatsTests.csReplace UnbufferedFileStream usage with posix_fadvise + RandomAccess+33/-21
Replace UnbufferedFileStream usage with posix_fadvise + RandomAccess
• Refactors the test to write/read a temp file using File.OpenHandle + RandomAccess.Read. On Unix, calls posix_fadvise(DONTNEED) to reduce cache effects before reading, then asserts disk IO counters increased (with OSX ops caveat).
NOTICE.mdRemove Mono.Posix.NETStandard from NOTICE+0/-1
Remove Mono.Posix.NETStandard from NOTICE
• Removes the Mono.Posix.NETStandard entry from the third-party notice list, consistent with it no longer being part of the shipped/native component set.
1. Stale slnf project reference✓ Resolved🐞 Bug≡ Correctness
Description
KurrentDB.Native was removed/deleted, but KurrentDB.ContainerTests.slnf still references
src\\KurrentDB.Native\\KurrentDB.Native.csproj, which can break CI/tooling that loads/builds using
that solution filter. This mismatch is introduced by the project removal in this PR without updating
the filter.
The main solution no longer includes KurrentDB.Native, but the container test solution filter still
lists it as a project, so the filter can reference a non-existent project file.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
`KurrentDB.ContainerTests.slnf` still lists the deleted `src/KurrentDB.Native/KurrentDB.Native.csproj`, so loading/building the solution filter can fail after this PR.
### Issue Context
The PR removes `KurrentDB.Native` from the main solution and deletes the project, but doesn’t update the container-tests solution filter.
### Fix Focus Areas
- KurrentDB.ContainerTests.slnf[2-45]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
The PR removes Mono.Posix.NETStandard from NOTICE.md and from qodana.yaml dependencyOverrides, but
adds Mono.Posix.NETStandard as a direct PackageReference in KurrentDB.SystemRuntime.Tests, which can
cause NOTICE/license-audit CI failures. This leaves license metadata inconsistent with the
solution’s restored dependency set.
- # the referenced license file is not trivial but appears to imply that this library is MIT- - name: "Mono.Posix.NETStandard"- version: "1.0.0"- licenses:- - key: "MIT"- url: "https://github.com/mono/mono/blob/main/LICENSE"-
Evidence
The test project explicitly references Mono.Posix, while the repository’s license metadata files no
longer include a corresponding entry/override (and the NOTICE section where it would appear
alphabetically no longer lists it).
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
`Mono.Posix.NETStandard` is now a direct dependency of `KurrentDB.SystemRuntime.Tests`, but the PR removed the corresponding entries from `NOTICE.md` and the Qodana `dependencyOverrides`, creating an inconsistency that can break license-audit/NOTICE validation.
### Issue Context
The package appears to have been removed along with `KurrentDB.Native`, but it is reintroduced in this PR for tests.
### Fix Focus Areas
- src/KurrentDB.SystemRuntime.Tests/KurrentDB.SystemRuntime.Tests.csproj[2-9]
- qodana.yaml[28-56]
- NOTICE.md[116-123]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
3. Flaky Linux disk IO test✓ Resolved🐞 Bug☼ Reliability
Description
ProcessStatsTests asserts Linux physical disk counters (from /proc/self/io read_bytes/write_bytes)
increased, but attempts to force physical reads only via posix_fadvise(DONTNEED), which is advisory
and environment/filesystem-dependent. This can make the test intermittently fail on Linux runners
(e.g., cache not evicted, tmpfs/overlayfs semantics).
+ private static string ReadAllText(string filePath) {+ using var handle = File.OpenHandle(filePath);++ if (RuntimeInformation.IsUnix) {+ // reset cache for this file, so the OS really reads it from disk+ int r;+ do {+ r = Syscall.posix_fadvise(handle.DangerousGetHandle().ToInt32(), 0, 0, PosixFadviseAdvice.POSIX_FADV_DONTNEED);+ } while (UnixMarshal.ShouldRetrySyscall(r));+ UnixMarshal.ThrowExceptionForLastErrorIf(r);+ }++ Span<byte> buffer = stackalloc byte[128];+ var read = RandomAccess.Read(handle, buffer, 0);+ return Encoding.UTF8.GetString(buffer[..read]);+ }
Evidence
The production code’s Linux implementation uses /proc/self/io physical counters, while the test
performs a normal buffered read and relies on a best-effort cache hint before asserting those
physical counters increased.
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution
### Issue description
The test tries to validate `ProcessStats.GetDiskIoLinux()` using assertions on `ReadBytes`/`WrittenBytes`, but its cache-avoidance mechanism (`posix_fadvise(...DONTNEED)` + buffered read) is not deterministic across Linux environments.
### Issue Context
`GetDiskIoLinux()` reads `/proc/self/io`’s `read_bytes`/`write_bytes` (physical I/O). Buffered reads may not increment `read_bytes` if served from page cache.
### Fix Focus Areas
- src/KurrentDB.SystemRuntime.Tests/ProcessStatsTests.cs[35-69]
- src/KurrentDB.SystemRuntime/Diagnostics/ProcessStats.cs[23-51]
ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools
Inok
changed the title
Remove UnbufferedFileStream and replace its usage with a regular pooled stream
[DB-2193] Remove UnbufferedFileStream and replace its usage with a regular pooled stream
Jul 29, 2026
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
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.
UnbufferedFileStreamattempts to do direct IO (NO_BUFFERING / O_DIRECT). However:So I switched PTable loading to the universal (Unix) path and removed this custom stream with all its internals.