Skip to content

Poorly performing hash used in the DBI/EE #11466

Closed

Description

@hoyosjs

Update: Exception.ToString() also hits this code path and so we are leaving it in .NET 9 for futher investigation

There are a few places in the DBI that rely on CordbSafeHashTable/CHashTableAndData such as

  • CordbHashTableEnum
  • CordbProcess
  • CordbClass
  • CordbAppDomain
  • CordbModule
  • CordbFunction

The backing hash table, CHashTable, doesn't grow as items keep getting added. This results in a steep performance degradation as the collections grow larger. Common reports include difficulty loading dumps containing thousands of modules. A possible solution would be to replace CHashTable with an SHash.

Activity

  1. self-assigned this
    on Nov 14, 2018
  2. transferred this issue fromdotnet/coreclron Jan 31, 2020
  3. added this to the Future milestone on Jan 31, 2020
  4. hoyosjs commented on Oct 14, 2020

    @hoyosjs
    MemberAuthor

    Related to #11056

  5. jkotas commented on Aug 10, 2023

    @jkotas
    Member

    Internal Microsoft team reported that they see a contention around access to DebuggerMethodInfoTable hashtable in a process that throws a lot of exceptions:

    image

    DebuggerMethodInfoTable is implemented as CHashTableAndData.

  6. modified the milestones: Future, 9.0.0 on Aug 10, 2023
  7. changed the title [-]Poorly performing hash used in the DBI[/-] [+]Poorly performing hash used in the DBI/EE[/+] on Oct 23, 2023
  8. added
    enhancement
    on Oct 23, 2023
  9. modified the milestones: 9.0.0, 10.0.0 on Jul 23, 2024
  10. steveisok commented on Jul 1, 2025

    @steveisok
    Member

    @hoyosjs part of me wants to see if we can pull this off in 10. Probably a tad too late to be aggressive. I suspect this might be able to come to some conclusion in 11.

  11. modified the milestones: 10.0.0, 11.0.0 on Jul 7, 2025
  12. modified the milestones: 11.0.0, 12.0.0 on Jul 28, 2026
  13. hoyosjs commented on Aug 13, 2026

    @hoyosjs
    MemberAuthor

    I audited the remaining CordbSafeHashTable and CHashTableAndData users, including an independent rubber-duck review with Claude Opus 4.8.

    The highest-cardinality, lower-risk right-side tables are the CordbModule class, function, and native-code caches. These are not exposed through CordbHashTableEnum, so they can move to SHash without changing COM enumeration behavior.

    The remaining migrations have these dependencies:

    • CordbHashTableEnum stores a HASHFIND cursor and supports cloning an enumeration in progress. A replacement needs to preserve Next, Skip, Reset, and Clone. Snapshot-backed enumeration appears to be the safest option.
    • Cordb hash tables own internal references. Any replacement must preserve exactly-once InternalAddRef and InternalRelease behavior across insertion, removal, transfer, neutering, and destruction.
    • DebuggerMethodInfoTable::ClearMethodsOfModule deletes the current entry while enumerating. This relies on FindNextEntry advancing the cursor before returning the entry.
    • DebuggerMethodInfoTable is DAC-visible and is likely the most important remaining EE performance target, especially for exception-heavy workloads.
    • DebuggerPatchTable permits duplicate keys and explicitly orders matching patches by controller type within bucket chains.
    • DebuggerPatchTable exposes stable entry indices, directly manipulates bucket links, and publishes storage offsets for cross-process and DAC access. It should remain on its specialized representation unless those requirements are modeled explicitly.
    • No contractual dependence on ordinary Cordb hash-table enumeration order was found. The current implementation nevertheless exposes bucket order with newest entries first within a bucket.

    The first PR will therefore migrate only the three CordbModule caches. Follow-up work should decouple CordbHashTableEnum from HASHFIND, make method-info removal explicitly iterator-safe, and define the required DAC representation before moving EE tables.

    Note

    This comment was generated with GitHub Copilot.

  14. added
    in-pr
    on Oct 21, 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-coreclrenhancementin-prtenet-performance

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions