Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Rewrite of Array.Copy fast path in C# - #27634

Merged
jkotas merged 9 commits into
dotnet:masterfrom
jkotas:array-copy
Nov 3, 2019
Merged

jkotas merged 9 commits into
dotnet:masterfrom
jkotas:array-copy

Conversation

@jkotas

@jkotas jkotas commented Nov 2, 2019

Copy link
Copy Markdown
Member

Contributes to #27106

@jkotas

jkotas commented Nov 2, 2019

Copy link
Copy Markdown
Member Author

This is greatly reducing the fixed Array.Copy overhead for common cases. E.g. Copying byte array of length one:

  • Array.Copy(Array, Array, int): 2.3x faster
  • Array.Copy(Array, int, Array, int, int): 1.5x faster

@jkotas

jkotas commented Nov 2, 2019

Copy link
Copy Markdown
Member Author

Also, this is fixing the performance penalty of the Array.Copy(Array, Array, int) overload for common cases. This overload is faster than the more verbose Array.Copy(Array, int, Array, int, int) one for the typical cases. We can switch the places that used to explicitly pass the start index as 0 to avoid this penalty back to the less verbose overload.

cc @stephentoub

@stephentoub

Copy link
Copy Markdown
Member

We can switch the places that used to explicitly pass the start index as 0 to avoid this penalty back to the less verbose overload.

Nice. I'm always a fan of both simpler and faster :) I can do so separately in corefx. Do you want to do it in corelib as part of this PR?

@jkotas

jkotas commented Nov 2, 2019

Copy link
Copy Markdown
Member Author

Do you want to do it in corelib as part of this PR?

My plan was to do that as follow up PR.

@jkotas
jkotas requested a review from VSadov November 2, 2019 17:19
Comment thread src/System.Private.CoreLib/src/System/Array.CoreCLR.cs
Comment thread src/System.Private.CoreLib/src/System/Array.CoreCLR.cs
Comment thread src/System.Private.CoreLib/src/System/Array.CoreCLR.cs
Comment thread src/classlibnative/bcltype/arraynative.cpp
Comment thread src/vm/ecalllist.h
Comment thread src/System.Private.CoreLib/src/System/Array.CoreCLR.cs
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants