Open timcassell opened 8 months ago
Tagging subscribers to this area: @dotnet/area-system-linq See info in area-owners.md if you want to be subscribed.
Author: | timcassell |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Linq`, `untriaged` |
Milestone: | - |
Tagging subscribers to this area: @dotnet/area-system-linq-parallel See info in area-owners.md if you want to be subscribed.
Author: | timcassell |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Linq`, `area-System.Linq.Parallel`, `untriaged` |
Milestone: | - |
Some of the methods that you listed such as Append
, Prepend
, Chunk
, ToHashSet
and TryGetNonEnumeratedCount
are inherently non-parallelizable. I'm guessing they wouldn't be parallel as such, only accelerator methods mapping ParallelEnumerable values to the sequential implementations?
Some of the methods that you listed such as
Append
,Prepend
,Chunk
,ToHashSet
andTryGetNonEnumeratedCount
are inherently non-parallelizable. I'm guessing they wouldn't be parallel as such, only accelerator methods mapping ParallelEnumerable values to the sequential implementations?
Exactly.
Also, I'm sure I missed some new overloads for existing extensions (like ElementAt
with a System.Index
parameter). Basically I think the API surface should match like the intro-to-plinq documentation states, even though some can't actually be parallelized.
Background and motivation
The documentation states "PLINQ implements the full set of LINQ standard query operators as extension methods for the System.Linq namespace and has additional operators for parallel operations.", but some new extensions were added to
System.Linq.Enumerable
that are missing inSystem.Linq.ParallelEnumerable
. I propose they be added so that further queries will continue to be parallelizable (even if some extensions can't be parallelized, they should still returnParallelQuery<T>
).API Proposal
All the missing extensions from
System.Linq.Enumerable
, with the same shape (I didn't bother to write out the full declarations for brevity).And the new .Net 9 extensions:
API Usage
Alternative Designs
Use
.AsSequential()
before using the new extensions.Risks
New extensions may not run in parallel (but that's already called out in PLINQ documentation).