-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Follow up on Scatter/Gather API changes #58447
Conversation
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsThis PR addresses some feedback that was provided on #57424 after it was merged. cc @stephentoub
|
src/libraries/System.IO.FileSystem/tests/RandomAccess/NoBuffering.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.IO.FileSystem/tests/RandomAccess/NoBuffering.Windows.cs
Outdated
Show resolved
Hide resolved
// Using segments with a length of twice the page size adheres to FILE_FLAG_NO_BUFFERING's | ||
// requirements but not the scatter/gather APIs'. The RandomAccess implementation will | ||
// see it and issue sequential read/write syscalls per segment, instead of one | ||
// scatter/gather syscall. This test verifies that fallback behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It verifies the fallback behavior when the length requirement isn't met but the others are, yes? What about when, say, the alignment requirement isn't met? Do we already have tests for that elsewhere?
src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Stephen Toub <stoub@microsoft.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall LGTM, but please add a test for a list of empty buffers.
src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Windows.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thank you @teo-tsirpanis !
@adamsitnik, @stephentoub, any additional feedback? |
* Allocate an array of memory handles only if needed. * Remove an unnecessary variable in the multiple-syscall write gather. * Actually verify the content read by the read scatter operation. * Delay allocating native memory. * Verify that the whole file was read in the scatter/gather test. * Test the case when the scatter/gather buffers are acceptable by the Windows API. * Avoid null pointer dereferences when passing an empty segment array. * Test performing scatter/gather I/O with an empty segment array. Co-authored-by: Stephen Toub <stoub@microsoft.com>
…s et. al. (#58423) * Move checking and pinning Windows vectored I/O buffers to a dedicated method. * Refactor the scatter/gather APIs to use the common checking method. And use pinned GCHandles and IntPtrs instead of MemoryHandles when passing the segment array to the bottom-most method. * Shorten the name of the buffer-checking method. * Directly get the pinned array's address instead of calling GCHandle.AddrOfPinnedObject. * Refactor the error handling logic in TryPrepareScatterGatherBuffers. * Allocate the segment array from native memory and at TryPrepareScatterGatherBuffers. * Cache the page size on a static readonly field and add a couple of TODOs. * Make the memory handlers readonly structs. * Add a test. * Reorder some methods with PR feedback taken into consideration. * Stop special-casing scatter/gather operations with zero or one buffer. * Factor the cleaning-up of the segment buffers into a separate method. * Follow up on Scatter/Gather API changes (#58447) * Allocate an array of memory handles only if needed. * Remove an unnecessary variable in the multiple-syscall write gather. * Actually verify the content read by the read scatter operation. * Delay allocating native memory. * Verify that the whole file was read in the scatter/gather test. * Test the case when the scatter/gather buffers are acceptable by the Windows API. * Avoid null pointer dereferences when passing an empty segment array. * Test performing scatter/gather I/O with an empty segment array. Co-authored-by: Stephen Toub <stoub@microsoft.com> Co-authored-by: Theodore Tsirpanis <teo.tsirpanis.718@gmail.com> Co-authored-by: Theodore Tsirpanis <12659251+teo-tsirpanis@users.noreply.github.com> Co-authored-by: Stephen Toub <stoub@microsoft.com>
This PR addresses some feedback that was provided on #57424 after it was merged.
cc @stephentoub