Skip to content

Reduced .NET8 R2R performance  #96242

Closed

Description

@JensNordenbro

Description

On arm64, using PublishReadyToRun on the attached project; you will get reduced performance using .NET8 (not present in NET7, NET6).

dotnet publish .\Arm64Net8JitError.csproj -f net6.0-windows -r win-arm64 -c Release --no-self-contained -p:PublishReadyToRun=true -o error_62_net6
 
dotnet publish .\Arm64Net8JitError.csproj -f net8.0-windows -r win-arm64 -c Release --no-self-contained -p:PublishReadyToRun=true -o error_63_net8

On my machine:
NET6: 10ms
NET8: 650ms

To help you guys get started, we have extracted a minimal reproduce project that triggers the error from a real application if you wonder why the app has no apparent purpose.

Changing from struct to class on Point2D will remove the problem.
Arm64Net8JitError.zip

Reproduction Steps

Start program published with parameter PublishReadyToRun:true and press the one button and get a messagebox with the init time to spot the difference.

Expected behavior

Non regressed performance.

Actual behavior

Really bad performance -> real world applicaton starts 10 times slower. Attached benchmark app is even slower than that.

Regression?

Yes, works in NET6.0, NET7.0

Known Workarounds

Convert Point2D struct to class instead.

Configuration

See description.

Other information

We target imx8MPlus.

Activity

  1. ghost added
    untriagedNew issue has not been triaged by the area owner
    on Dec 21, 2023
  2. changed the title [-]Reduce .NET8 R2R performance [/-] [+]Reduced .NET8 R2R performance [/+] on Dec 21, 2023
  3. janvorli commented on Dec 27, 2023

    @janvorli
    Member
  4. JensNordenbro commented on Feb 26, 2024

    @JensNordenbro
    Author

    Any comments on this issue?

  5. removed
    untriagedNew issue has not been triaged by the area owner
    on Jun 21, 2024
  6. added this to the 9.0.0 milestone on Jun 21, 2024
  7. steveisok commented on Jun 21, 2024

    @steveisok
    Member

    @ivdiazsa please run this through the ringer and see if you get the same results.

  8. AndyAyersMS commented on Aug 9, 2024

    @AndyAyersMS
    Member

    Looks like in .NET 8 there is one method with unusually long jitting time (found via the jit stats tab of a perfview run) that likely accounts for the startup time issue you're seeing:

    image

    that method does not appear in the .NET 6 jit stats, so presumably it was prejitted in .NET 6 but not in .NET 8.

    So the question is, why doesn't that method get prejitted in .NET 8? That will take a bit more digging.

  9. AndyAyersMS commented on Aug 9, 2024

    @AndyAyersMS
    Member

    Seems like per r2r dump the method does get prejitted, so perhaps the runtime is deciding the method can't be used for some reason? (runtime might also toss the entire R2R payload).

    There is an ETW bit in the method load event for this, but perfview doesn't parse it yet in the raw payload.

  10. ivdiazsa commented on Aug 9, 2024

    @ivdiazsa
    Contributor

    Thank you very much for the insight Andy. What might be the possible reasons the runtime might decide that and discard everything? And how would we investigate such a case?

  11. removed this from the 9.0.0 milestone on Aug 9, 2024
  12. 4 remaining items

  13. jkotas commented on Aug 9, 2024

    @jkotas
    Member

    @ivdiazsa I see that you have modified the milestone to 10.0. The PointD type is very simple. It looks like a pretty bad crossgen2 bug to me if we are not able to load it. You may want to reconsider.

  14. JensNordenbro commented on Aug 10, 2024

    @JensNordenbro
    Author

    @ivdiazsa, for us, labling this 10.0, makes the prospect of moving from net6.0-lts problematic. Either we stay=) insecure or we move to net8.0 =) slow.

  15. modified the milestones: 10.0.0, 9.0.0 on Aug 10, 2024
  16. steveisok commented on Aug 10, 2024

    @steveisok
    Member

    @ivdiazsa, for us, labling this 10.0, makes the prospect of moving from net6.0-lts problematic. Either we stay=) insecure or we move to net8.0 =) slow.

    This is something we'll prioritize now and is highly likely to make its way back to net8.

  17. ivdiazsa commented on Aug 10, 2024

    @ivdiazsa
    Contributor

    Thanks a lot for the detailed explanation and guidance @jkotas. Will prioritize it and get to investigate it on Monday.

  18. ivdiazsa commented on Aug 15, 2024

    @ivdiazsa
    Contributor

    @JensNordenbro Hi, we've been researching and are currently developing a fix. While investigating, we found that your repro app has an [assembly: Guid("Guid goes here")] annotation in Properties/AssemblyInfo.cs file. Considering you also have [assembly: ComVisible(false)], is there a reason you might need the Guid? I ask because due to where the bug lies in the type system, if you remove that Guid clause, the regression disappears. I got ~5ms on my testing machine, which is fairly similar to .NET 6 and .NET 7. Would this work as a temporary workaround?

  19. linked a pull request that will close this issueFix Type System Equivalence Checks #106498on Aug 15, 2024
  20. JensNordenbro commented on Aug 16, 2024

    @JensNordenbro
    Author

    Hi @ivdiazsa !

    I will try to schedule a real investigation on the real app but I think it might take some time before we get to that. (summer, ...)

    • I will get back with our results unless you guys beet me to the punch!

    Nice to see progress!

  21. added
    in-prThere is an active PR which will close this issue when it is merged
    on Aug 16, 2024
  22. ivdiazsa commented on Aug 19, 2024

    @ivdiazsa
    Contributor

    Hi @JensNordenbro! We've finished working on the fix and will soon begin working on the backport to .NET 8.

  23. ivdiazsa commented on Aug 21, 2024

    @ivdiazsa
    Contributor

    Hi @JensNordenbro! We've finished working on the fix and will soon begin working on the backport to .NET 8.

    The backport has been successfully completed. The fix will be available on the .NET 8.0.10 release.

  24. JensNordenbro commented on Aug 23, 2024

    @JensNordenbro
    Author

    Thanks @ivdiazsa!
    Once started, this was quick 😄

  25. locked and limited conversation to collaborators on Sep 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

arch-arm64in-prThere is an active PR which will close this issue when it is mergedos-windowstenet-performancePerformance related issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions