Conversation
Each flush copied the pending range into a temporary array before the container copied it again, and disposing copied the stream buffer even though nothing writes to it afterwards. Requiring the pending writes to end within the stream length also stops a SetLength truncation from persisting the cut-off part of a pending write.
|
This pull request is merged. |
[Medium impact] The PR appears safe to merge; the previous buffer-sharing issue is fixed.
|
vbreuss
enabled auto-merge (squash)
November 28, 2026 14:45
|
🚀 Benchmark ResultsCompared to Memory
CompleteTestBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) Intel Xeon 6975P-C 3.08GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 MockCreationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V74 2.60GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 EnumerationBenchmarks
BenchmarkDotNet v0.15.8, Linux Ubuntu 26.04.1 LTS (Resolute Raccoon) AMD EPYC 9V45 4.51GHz, 1 CPU, 4 logical and 2 physical cores .NET SDK 11.0.100 [Host] : .NET 10.0.15 (10.0.15, 10.0.1526.53008), X64 RyuJIT x86-64-v4 Job=InProcess Toolchain=InProcessEmitToolchain IterationCount=15 LaunchCount=1 WarmupCount=10 |
github-actions Bot
added a commit
that referenced
this pull request
Nov 29, 2026
…en flushing a mock file stream (#1242) by Valentin Breuß
github-actions Bot
added a commit
that referenced
this pull request
Nov 29, 2026
…en flushing a mock file stream (#1242) by Valentin Breuß
|
This is addressed in release v8.1.2. |
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.



Writing through a mock
FileStreamcopied the data three times: into theMemoryStream, into a temporary array on flush, and into the new container content. Disposing copied the stream buffer once more, although nothing writes to it afterwards.The flush now passes the stream buffer with index and count to
IStorageContainer.WriteRange, so the temporary copy is gone, and on dispose the container takes over the buffer when it holds exactly the new file content.BytesChangedEventArgscarries the new container content with offset and count, so other streams on the same file copy only the changed range. All touched types are internal.This also fixes a bug: after opening a 5-byte file, writing 10 bytes and calling
SetLength(5), the mock kept a length of 10 and persisted the cut-off part of the pending write, while the real file system keeps 5 bytes. The new testSetLength_Truncate_AfterPendingWriteBeyondNewLength_ShouldPersistNewLengthpasses on all file system rows, including the real file system.