Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.
/ corefx Public archive

Temporarily removing use of ReadOnlySpan indexer in Runtime.Extensions #25326

Merged
merged 6 commits into from
Nov 22, 2017

Conversation

ahsonkhan
Copy link
Member

@ahsonkhan ahsonkhan commented Nov 18, 2017

Removing the use of the ReadOnlySpan indexer to help the implementation change go through with the least disabling of tests.

This is a temporary workaround that is required to reduce the number of failing tests that would need to be disabled due to the change to ReadOnlySpan indexer to return ref readonly, here: dotnet/coreclr#14727

cc @weshaggard, @stephentoub, @KrzysztofCwalina, @jkotas

This change should be reverted once the change propogates (and the tests enabled): https://github.com/dotnet/coreclr/issues/15089

@stephentoub
Copy link
Member

stephentoub commented Nov 18, 2017

Removing the use of the ReadOnlySpan indexer to help the implementation change go through with the least disabling of tests.

Why is this needed? What breaks without it?

I realize the change is intended to only be temporary, but it also adds a gigantic expense to some core methods. I don't like the idea of it being in the code base, even temporarily.

@jkotas
Copy link
Member

jkotas commented Nov 18, 2017

I don't like the idea of it being in the code base, even temporarily.

You can unsafe casts the ReadOnlySpan to Span to address this.

@jkotas
Copy link
Member

jkotas commented Nov 18, 2017

So what is your plan to get this through? Which PR will got first, second, third, ... ?

@ahsonkhan
Copy link
Member Author

ahsonkhan commented Nov 18, 2017

Why is this needed? What breaks without it?

The tests in coreclr depend on packages from corefx which won't have the updated ref readonly indexer. So, the tests won't pass in either repo (without some effort to break the dependencoes).

You can unsafe casts the ReadOnlySpan to Span to address this.

That is a good idea to avoid the performance hit. I will make the change.

So what is your plan to get this through? Which PR will got first, second, third, ... ?

  1. This PR (which will publish new packages to myget)
  2. CoreCLR gets updated to point to the new version of the packages
  3. Followed by Change ReadOnlySpan indexer to return ref readonly coreclr#14727 goes green and gets merged.
  4. Then, we can merge the following PR (when we get the coreclr update): ReadOnlySpan indexer now returns ref readonly #24929

@jkotas
Copy link
Member

jkotas commented Nov 18, 2017

And the plan for UWP NETNative?


unsafe
{
preamble = new Span<byte>(Unsafe.AsPointer<byte>(ref readonlyPreamble.DangerousGetPinnableReference()), readonlyPreamble.Length);
Copy link
Member

Choose a reason for hiding this comment

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

This has GC hole...

Copy link
Member

Choose a reason for hiding this comment

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

You need to pin the pointer while you are manipulating it.

@ahsonkhan
Copy link
Member Author

And the plan for UWP NETNative?

When step 3 happens (i.e. change to CoreCLR), I would make the change on the .NET Native side as well at the same time.

We can then merge the corefx PR (step 4), when we get the coreclr and .NET Native update.

Example of PRs that would need to be merged together with the corefx change (from step 4):
#25362
#25406

cc @davidwrighton, @tijoytom

@ahsonkhan ahsonkhan merged commit 1d95739 into dotnet:master Nov 22, 2017
@ahsonkhan ahsonkhan deleted the RemoveSpanIndexer branch November 22, 2017 10:36
ahsonkhan added a commit to ahsonkhan/corefx that referenced this pull request Dec 16, 2017
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
dotnet/corefx#25326)

* Temporarily removing use of Span indexer in Runtime.Extensions

* Use Unsafe to cast ReadOnlySpan to Span.

* Only add project reference to Unsafe if target group isn't uapaot

* Pin the pointer from DangerousGetPinnableReference

* Remove unnecessary reference to compilerservices

* Remove the reference from the csproj


Commit migrated from dotnet/corefx@1d95739
picenka21 pushed a commit to picenka21/runtime that referenced this pull request Feb 18, 2022
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.

4 participants