Improve UnwindInfoTable's performance#125545
Conversation
75cd28d to
7358ca6
Compare
|
Storing in a buffer and flushing with two locks actually led to better performance of the test case mentioned in #123124 (comment).
|
There was a problem hiding this comment.
Pull request overview
This PR optimizes CoreCLR’s Windows x64 unwind-info publishing by buffering RUNTIME_FUNCTION entries and batch-merging them into the OS growable function table, aiming to reduce overhead from frequent register/unregister operations during JIT.
Changes:
- Introduces a per-
UnwindInfoTablepending buffer and aFlushPendingEntries()path to batch-merge unwind entries. - Splits the single unwind-info lock into publish vs pending locks to reduce contention.
- Updates Crst type definitions / generated mappings for the new lock types.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/coreclr/vm/codeman.h | Adds pending buffer fields and refactors APIs around buffered publishing. |
| src/coreclr/vm/codeman.cpp | Implements pending-buffer accumulation, flush/merge logic, and new lock usage. |
| src/coreclr/inc/CrstTypes.def | Defines UnwindInfoTablePublishLock and UnwindInfoTablePendingLock and their ordering. |
| src/coreclr/inc/crsttypes_generated.h | Updates generated Crst enum/name/level maps to include new locks. |
Comments suppressed due to low confidence (1)
src/coreclr/vm/codeman.cpp:489
PublishUnwindInfoForMethodcallsAddToUnwindInfoTable(...)and then callsFlushPendingEntries(), butAddToUnwindInfoTablealready flushes at the end of the batch. This adds an extra lock acquisition on the publish path; consider removing the extra flush or restructuring so flushing happens in only one place.
unwindInfo->AddToUnwindInfoTable(methodUnwindData, methodUnwindDataCount);
}
}
/*****************************************************************************/
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
src/coreclr/vm/codeman.cpp:1
- Removal only searches the published table and ignores entries that are still in the pending buffer. If a method is unpublished before its unwind data is flushed, the pending entry can later be published to the OS (stale unwind info), and removal will incorrectly report not found. Fix by also searching/removing matching entries from the pending buffer under
s_pUnwindInfoTablePendingLock(and/or forcing a flush before attempting removal) so unpublish is correct regardless of whether the entry was already published.
// Licensed to the .NET Foundation under one or more agreements.
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
Co-authored-by: Jan Kotas <jkotas@microsoft.com>
|
What does the perf look like with the latest delta? |
|
These are the results with the latest changes
|
AaronRobinsonMSFT
left a comment
There was a problem hiding this comment.
Two nits I'd personally like to see fix, but other than that, LGTM. Thanks!
|
/ba-g unrelated failure |
Place the entries of UnwindInfoTable in a buffer and flush such that we amortize the cost of the operations (pRtlAddGrowableFunctionTable + pRtlDeleteGrowableFunctionTable) to create the internal table of
RUNTIME_FUNCTIONs.Contributes to #123124.