Skip to content
This repository was archived by the owner on Nov 13, 2026. It is now read-only.

Buffer.BlockCopy optimization for arrays of same type - #1283

Merged
jkotas merged 2 commits into
dotnet:masterfrom
jamesqo:patch-3
May 17, 2016
Merged

jkotas merged 2 commits into
dotnet:masterfrom
jamesqo:patch-3

Conversation

@jamesqo

@jamesqo jamesqo commented May 16, 2016

Copy link
Copy Markdown
Contributor

Basically a port of dotnet/coreclr#4807 to corert.

Not sure if there's a way to apply the byte array-related optimizations from there as well here (so we can skip the first primitive typecheck as well, if either src or dst is a byte array) (how would you 'load' the byte array EETypePtr statically so you could compare it like src.EETypePtr == s_byteArrayTypePtr?).

cc @jkotas

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EETypePtr has custom operator!= that has non-trivial cost... .

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jkotas What about doing a raw pointer comparison, e.g. src.EETypePtr.ToPointer() == dst.EETypePtr.ToPointer()?

The latter overloads the operator ==, and it can be expensive.
@jamesqo

jamesqo commented May 16, 2016

Copy link
Copy Markdown
Contributor Author

@jkotas The feedback you made in #1282 has been addressed; thanks for responding.

@jkotas

jkotas commented May 16, 2016

Copy link
Copy Markdown
Member

LGTM. Thanks!

@jkotas
jkotas merged commit 29ed7d3 into dotnet:master May 17, 2016
@jamesqo
jamesqo deleted the patch-3 branch May 17, 2016 03:03
@jkotas

jkotas commented May 18, 2016

Copy link
Copy Markdown
Member

This fix is not right - it fails internal tests.

@jamesqo

jamesqo commented May 18, 2016 •

Copy link
Copy Markdown
Contributor Author

@jkotas How is that possible? Can two arrays have different ElementEETypes, but the same value for EETypePtr?

@jkotas

jkotas commented May 18, 2016

Copy link
Copy Markdown
Member

It breaks computation of uDstLen.

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.

3 participants