Make use of GetMany to improve perf of CopyTo - #2517
Merged
Manodasan Wignarajah (manodasanW) merged 13 commits intoAug 13, 2026
Conversation
Copy IList<string> values through a single IVector.GetMany ABI call with balanced HSTRING cleanup, falling back only when a provider returns fewer items. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: ddbd67fd-01c2-4b1b-b23f-f9eb0ad8f70e
Batch ICollection<T>.CopyTo through IVector<T>.GetMany across blittable, string, object, reference, value, nullable, key-value pair, Type, and Exception element categories. Add focused native-vector tests and string benchmark coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Validate native counts, preserve E_NOTIMPL fallback compatibility, correct GetMany vtable signatures, and add chunk-boundary string coverage. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No known conforming IVector implementation returns E_NOTIMPL from GetMany, so preserve normal failure propagation rather than masking incomplete providers. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Remove defensive count clamping because it cannot validate or repair a malformed native provider and conforming implementations must return at most the requested capacity. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
Use span copies for managed arrays and List<T> exposed through IVector<T>, while retaining the indexer fallback for arbitrary IList<T> implementations. Add coverage for offsets, limited capacity, empty requests, and each implementation path. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Keep the TestWinRT-dependent benchmark call commented until the corresponding native benchmark API is available. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Cover writable vectors and vector views for blittable, string, and projected object elements so GetMany improvements through LINQ ToArray remain measurable. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Move the 'GetMany' family out of 'IVectorMethods' and into specialized extension types in a new 'IVectorMethodsExtensions' file, mirroring the existing 'IListAdapterExtensions' and 'IEnumeratorAdapterExtensions' files, so that all specializations expose a uniform 'GetMany' member. Add a 'GetManyUnsafe' helper to 'IVectorVftbl', matching the '*Unsafe' convention used by all the other vtable types, and use it from all the 'GetMany' specializations. Update the interop generator to match the existing patterns: the element type dispatch in 'InteropMethodDefinitionFactory.IVectorMethods.GetMany' now uses the same switch expression shape as 'IList1Impl.GetMany', and the new 'InteropReferences' members follow the naming and documentation of the equivalent 'IListAdapter*' ones. Also simplify 'IListMethods<T>.CopyTo' with an early return, and complete the XML docs on all the new interface and reference members. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f9216861-f68c-437e-8f82-776d072bac2a
Sergio Pedri (Sergio0694)
approved these changes
Aug 13, 2026
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: f9216861-f68c-437e-8f82-776d072bac2a
Manodasan Wignarajah (manodasanW)
enabled auto-merge (squash)
August 13, 2026 22:04
Manodasan Wignarajah (manodasanW)
merged commit Aug 13, 2026
252d474
into
staging/3.0
13 checks passed
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.
Measured
IList<T>.CopyToover 100,000-element nativeIVector<T>instances using theCollectionsPerf.GetMany*benchmarks.intstringMeasured a native component calling
IVector<int>.GetManyon a managedint[]containing 100,000 elements.IList<T>indexer loopThe optimized path is approximately 5.6× faster, reducing per-item cost by ~82%, with no managed allocations reported.
IList<int>.ToArray()IList<string>.ToArray()IList<WrappedClass>.ToArray()IVectorView<int>.ToArray()IVectorView<WrappedClass>.ToArray()ToArray()benefits because LINQ allocates the destination array and invokesICollection<T>.CopyTo(), which now uses nativeGetMany.