Skip to content

Use a lock per UnwindInfoTable object instead of global lock#125545

Draft
eduardo-vp wants to merge 3 commits intodotnet:mainfrom
eduardo-vp:lock-per-UnwindInfoTableObject
Draft

Use a lock per UnwindInfoTable object instead of global lock#125545
eduardo-vp wants to merge 3 commits intodotnet:mainfrom
eduardo-vp:lock-per-UnwindInfoTableObject

Conversation

@eduardo-vp
Copy link
Member

@eduardo-vp eduardo-vp commented Mar 14, 2026

Will collect some numbers, in the meantime just checking for CI errors.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates CoreCLR’s Windows x64 unwind-info publishing to reduce lock contention by moving from a single global lock to a per-UnwindInfoTable lock, improving scalability when multiple code heaps publish unwind data concurrently.

Changes:

  • Add a per-table Crst (m_lock) to UnwindInfoTable.
  • Use the global lock only for lazy initialization, and use the per-table lock for steady-state add/remove operations.
  • Rework the slow-path growth to keep the UnwindInfoTable object stable (swap only the internal pTable array).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.

File Description
src/coreclr/vm/codeman.h Adds per-UnwindInfoTable lock member.
src/coreclr/vm/codeman.cpp Switches add/remove synchronization to per-table locking and updates the growth path to swap arrays in-place.

You can also share your feedback on Copilot code review. Take the survey.

Eduardo Velarde added 2 commits March 13, 2026 18:26
Copilot AI review requested due to automatic review settings March 14, 2026 01:29
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Reduces lock contention in CoreCLR’s Windows x64 unwind info publishing by moving from a single global UnwindInfoTable lock to a per-table lock (one per code range / code heap).

Changes:

  • Add a per-UnwindInfoTable Crst to synchronize table updates independently per range.
  • Keep the global lock only for lazy initialization of the per-range UnwindInfoTable.
  • Change table growth to preserve the UnwindInfoTable object (and its lock) while swapping the internal pTable array.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/coreclr/vm/codeman.h Adds a per-table Crst member to UnwindInfoTable.
src/coreclr/vm/codeman.cpp Uses global lock only for lazy init; uses per-table lock for add/remove and resizes by swapping pTable instead of replacing the object.

You can also share your feedback on Copilot code review. Take the survey.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants