Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deleting field sequences from LCL_FLD and VNF_PtrToArrElem #68986

Merged
merged 6 commits into from
May 27, 2022

Conversation

SingleAccretion
Copy link
Contributor

@SingleAccretion SingleAccretion commented May 6, 2022

The first round of deleting field sequences:

  1. From LCL_FLD: replace it with a ClassLayout* pointer (for now, unused). De-pessimize block morphing and block numbering, remove quirks from VN.
  2. From VNF_PtrToArrElem: not replaced by anything because it is not needed anymore.

Also includes clean up of DefinesLocalAddr and a miscellaneous fix for the numbering of return buffer locals.

The diffs are pretty nice, including the throughput ones, and come mainly from the deletion of fgMorphCanUseLclFldForCopy, but also from the array change. We see some regressions with CSEs and hoisting (there is one extreme case of this on x86 where 6 new SIMD CSEs trigger pathological RA behavior and we see it "spill the world", fortunately it is in a PMI-instantiated method). There are also a few cases where locals become tracked and optRemoveRedundantZeroInits no longer removes the explicit zero-initialization.

This also saves ~0.16% in memory consumption when CG-ing CoreLib.

Closes #12142.

@dotnet-issue-labeler dotnet-issue-labeler bot added the area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI label May 6, 2022
@ghost ghost added the community-contribution Indicates that the PR has been added by a community member label May 6, 2022
@ghost
Copy link

ghost commented May 6, 2022

Tagging subscribers to this area: @JulieLeeMSFT
See info in area-owners.md if you want to be subscribed.

Issue Details

The first round of deleting field sequences:

  1. From LCL_FLD: replace it with a ClassLayout* pointer (unused for now). De-pessimize block morphing and block numbering.
  2. From VNF_PtrToArrElem: not replaced by anything because it is not needed anymore.

Also includes clean up of DefinesLocalAddr and a miscellaneous fix for the numbering of return buffer locals.

We're expecting a good amount of positive diffs, mainly from the deletion of fgMorphCanUseLclFldForCopy, but also from the array change.

Depends on #68979.

Author: SingleAccretion
Assignees: -
Labels:

area-CodeGen-coreclr

Milestone: -

@SingleAccretion SingleAccretion changed the title Physical vn locals upstream Deleting field sequences from LCL_FLD and VNF_PtrToArrElem May 6, 2022
@SingleAccretion SingleAccretion force-pushed the Physical-VN-Locals-Upstream branch 5 times, most recently from 5a08623 to 9cd3379 Compare May 7, 2022 17:10
@SingleAccretion
Copy link
Contributor Author

@dotnet/jit-contrib I would like to request a run of stress and libraries stress for this change.

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@SingleAccretion SingleAccretion force-pushed the Physical-VN-Locals-Upstream branch 4 times, most recently from dfccd94 to 05ac8d1 Compare May 10, 2022 15:37
This was referenced May 12, 2022
@SingleAccretion SingleAccretion force-pushed the Physical-VN-Locals-Upstream branch 4 times, most recently from 615799d to 9c81107 Compare May 15, 2022 11:00
@SingleAccretion
Copy link
Contributor Author

@jakobbotsch could you please re-trigger the stress pipelines?

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@SingleAccretion
Copy link
Contributor Author

SingleAccretion commented May 16, 2022

That was quite a bit of red CI to interpret...

The runtime pipeline:

Stress:

Libraries stress:

@jakobbotsch
Copy link
Member

jakobbotsch commented May 16, 2022

I am however suspicious: there are two asserts, and a segfault on ARM64, and I do not see anything like that in the recent history of the libraries stress pipeline. It seems likely to be related; unfortunately, I am yet to figure out how can one look into an ARM dump without an ARM/64 machine.

In theory it should be loadable with x86 windbg, but I have not had much success. I can try looking at the dump on my rpi some time this week.

Run to make sure I don't lose it

@jakobbotsch
Copy link
Member

Unfortunate I ran into problems while analyzing the dump, I left a comment at
dotnet/diagnostics#2947 (comment).
Let's try a rerun.

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr libraries-jitstress

@SingleAccretion
Copy link
Contributor Author

@jakobbotsch I think this is ready for another stress run.

@jakobbotsch
Copy link
Member

/azp run runtime-coreclr jitstress, runtime-coreclr libraries-jitstress

@azure-pipelines
Copy link

Azure Pipelines successfully started running 2 pipeline(s).

@SingleAccretion
Copy link
Contributor Author

SingleAccretion commented May 19, 2022

The System.Memory.Tests failures are out (as expected).

Edit: regular CI hit the same crash inside S.T.J.Tests on Linux ARM.

Edit: two more failures on Linux_musl ARM. This is a bit surprising, the CI was green for this change yesterday, today's force push just removed the GC hole fix (now in main) from the commit list. So it almost seems like something in the upstream commit chain made the failures more apparent.

Edit: and said failures (or at least one of them) do appear to exist in the upstream too, e. g. the stack we see for System.Runtime.Tests AV is identical to the one seen in #20220518.16:

===========================================================================================================
/root/helix/work/workitem/e /root/helix/work/workitem/e
  Discovering: System.Runtime.Tests (method display = ClassAndMethod, method display options = None)
  Discovered:  System.Runtime.Tests (found 8065 of 8111 test cases)
  Starting:    System.Runtime.Tests (parallel test collections = on, max threads = 4)
Fatal error. System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
   at System.Numerics.BigInteger.AssertValid()
   at System.Numerics.BigInteger.CompareTo(System.Numerics.BigInteger)
   at System.Numerics.BigInteger.op_GreaterThan(System.Numerics.BigInteger, System.Numerics.BigInteger)
   at System.Tests.DecimalTests+BigDecimal.ScaleResult(System.Numerics.BigInteger ByRef, Int32 ByRef, Boolean)
   at System.Tests.DecimalTests+BigDecimal.Mul(BigDecimal, Boolean ByRef)
   at System.Tests.DecimalTests+BigIntegerMul.Test()
   at System.RuntimeMethodHandle.InvokeMethod(System.Object, Void**, System.Signature, Boolean)
   at System.Reflection.RuntimeMethodInfo.InvokeNonEmitUnsafe(System.Object, IntPtr*, System.Span`1<System.Object>, System.Reflection.BindingFlags)

Edit: more similar-looking AVs in another stress run.

Edit: on progress status - I have managed to set up things such that I can look into the ARM dumps with x86 WinDbg, next step is to download (1GB worth of) the S.T.J. minidump from the latest stress run, as the core dumps from regular CI do not appear to have enough managed information.

@jakobbotsch
Copy link
Member

@SingleAccretion I think given your investigations above that you don't need to block this PR on those GC holes. Are there any other known problems with this PR?

@SingleAccretion
Copy link
Contributor Author

SingleAccretion commented May 21, 2022

@jakobbotsch nothing that I am aware of.

I will investigate the dumps over the weekend, and if nothing comes up, will mark this as ready for review.

Edit, progress status: in all apparency the 1GB S.T.J. dump was too much for the x86 address space to handle (with WinDbg crashing). Perhaps I will be able to get something smaller from Sunday's libraries stress run...

Edit: we have a Linux ARM64 crash, but the dump was too big to upload...

Edit: will presume the GC holes above are #69657.

Move the responsibility of determining "entireness" to
its only caller that needed to do that: "DefinesLocal".

Add function headers.

No diffs.
Exposed by the more aggressive hoisting.
@SingleAccretion SingleAccretion marked this pull request as ready for review May 23, 2022 16:29
@SingleAccretion
Copy link
Contributor Author

This is finally ready for review.

Not sure what's up with Libraries Build windows x64 Debug.

@dotnet/jit-contrib, @jakobbotsch

@jakobbotsch jakobbotsch self-assigned this May 23, 2022
@jakobbotsch jakobbotsch self-requested a review May 23, 2022 16:43
{

haveCorrectFieldForVN =
compiler->info.compCompHnd->doesFieldBelongToClass(field->gtFldHnd, clsHnd);
Copy link
Member

Choose a reason for hiding this comment

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

This removes the only uses of this JIT-EE function, correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep. Will open an issue tracking deleting it completely.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good. @dotnet/jit-contrib we should keep in mind to delete this one together with the next JIT-EE update.

Copy link
Member

Choose a reason for hiding this comment

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

Also cc @sandreenko who will be happy to hear that :-)

Copy link
Member

@jakobbotsch jakobbotsch left a comment

Choose a reason for hiding this comment

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

Looks great to me, I love to see all the deletions :)

@jakobbotsch jakobbotsch merged commit f05fa01 into dotnet:main May 27, 2022
@SingleAccretion SingleAccretion deleted the Physical-VN-Locals-Upstream branch June 7, 2022 16:28
@ghost ghost locked as resolved and limited conversation to collaborators Jul 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-CodeGen-coreclr CLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI community-contribution Indicates that the PR has been added by a community member
Projects
None yet
Development

Successfully merging this pull request may close these issues.

JIT: inconsistent handling of GT_LCL_FLD in value numbering
2 participants