-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Relax RandomAccess type requirements, make all Read*|Write* methods work with non-seekable files #58381
Comments
Tagging subscribers to this area: @dotnet/area-system-io Issue DetailsIn .NET 6 we have introduced new type called As of today, all it's
But it's not a problem for it's internal implementation (used by runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Unix.cs Lines 33 to 38 in d033e1a
And we use it's internal API surface to workaround this limitation is
We should relax the public requirements and make This is going to require:
Everything motioned above should be a single PR. In the same or separate PR, the Unix implementation of overloads that accept multiple buffers should start using But it's going to allow to:
|
@adamsitnik Whats the current state of this? Why is your PR closed? |
It's still on my TODO list for 7.0. |
@adamsitnik Is this likely to make it into .NET 7? |
Unfortunately, we won't be able to get to this in .NET 7.0. We will consider it again during our .NET 8 planning. |
What would it take to move this forward? I've looked a fair amount at the Two potential problems I see are:
|
It would most likely be a matter of resurrecting #58506, solving merge conflicts and writing a breaking change doc. It would be great to take a fresh look at https://github.com/dotnet/runtime/pull/58506/files#r701031142 and see whether it can be improved. |
One of the main features of |
I am going to send a PR for that. |
In .NET 6 we have introduced new type called
RandomAccess
that allows for reading and writing to specific file offset.As of today, all it's
Read*
andWrite*
methods throw when given handle points to a non-seekable file like socket or pipe:runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.cs
Line 251 in d033e1a
But it's not a problem for it's internal implementation (used by
FileStream
):runtime/src/libraries/System.Private.CoreLib/src/System/IO/RandomAccess.Unix.cs
Lines 33 to 38 in d033e1a
And we use it's internal API surface to workaround this limitation is
CoreLib
(mind the call to RandomAccess.WriteAtOffset (internal), not RandomAccess.Write (public):runtime/src/libraries/System.Private.CoreLib/src/System/IO/File.cs
Line 382 in d033e1a
We should relax the public requirements and make
RandomAccess
work with non-seekable files.This is going to require:
Everything motioned above should be a single PR. In the same or separate PR, the Unix implementation of overloads that accept multiple buffers should start using
readv
andwritev
sys-calls. This should be relatively easy (just search forpreadv
andpwritev
and reuse the patterns)But it's going to allow to:
FileStream
to a very lightweightRandomAccess
everywhere where we don't need buffering in BCL (and ofc outside of BCL). Sample perf gains: File.*AllText* optimizations #58167 (comment)The text was updated successfully, but these errors were encountered: