Skip to content

Lock contention in StackTrace/Exception.ToString() #90563

Closed

Description

@jkotas

Lock contention has been observed in a real-world service at the following callstacks during a failover period where a lot of exceptions are thrown:

image

Activity

  1. added this to the 8.0.0 milestone on Aug 15, 2023
  2. jkotas commented on Aug 15, 2023

    @jkotas
    MemberAuthor

    The contention is caused by <DebugType>full</DebugType> debug format by some of the libraries. This debug format makes the runtime switch to read-write variant of the metadata readers that is unnecessary and introduces the contention.

    Standalone repro: https://gist.github.com/jkotas/617109b64d9b0ad52b491cdf021b2f8a

    Actual results

    20 core dev box

    • DebugType=portable (default in .NET Core/5+):
      rmdir /s /q bin obj && dotnet build -c Release && dotnet run -c Release
      21,000 exceptions thrown, formatted and handled per second

    • DebugType=full (default in .NET Framework):
      rmdir /s /q bin obj && dotnet build -c Release /p:DebugType=full && dotnet run -c Release
      1,400 exceptions thrown, formatted and handled per second (more than one order of magnitude less)

    Expected results

    DebugType=portable and DebugType=full should be able to achieve a roughly same exception handling rate.

  3. ghost added
    in-prThere is an active PR which will close this issue when it is merged
    on Oct 19, 2023
  4. ghost removed
    in-prThere is an active PR which will close this issue when it is merged
    on Dec 9, 2023
  5. modified the milestones: 8.0.0, 10.0.0 on Aug 20, 2024
  6. modified the milestones: 10.0.0, 11.0.0 on Aug 5, 2025
  7. added
    in-prThere is an active PR which will close this issue when it is merged
    on Jun 25, 2026
  8. added a commit that references this issue on Jul 13, 2026
    f98c7ad
  9. added a commit that references this issue on Jul 15, 2026
    a22bcef
  10. locked and limited conversation to collaborators on Aug 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

area-Diagnostics-coreclrin-prThere is an active PR which will close this issue when it is mergedtenet-performancePerformance related issue

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions