Skip to content

[cDAC] Reuse lookahead stack-unwind contexts - #136589

Merged
max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:cdac-reuse-stackwalk-caller-context
Nov 2, 2026
Merged

max-charlamb merged 2 commits into
dotnet:mainfrom
max-charlamb:cdac-reuse-stackwalk-caller-context

Conversation

@max-charlamb

@max-charlamb max-charlamb commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Reuse the caller context already unwound while checking for skipped explicit frames, instead of unwinding the same managed frame again when advancing the stack walk.

The cached context belongs to one stack walk. Keep it while only the explicit-frame iterator advances; discard it after advancing the managed context or processing an explicit/native transition. Interpreter advancement keeps its separate virtual-unwind path.

Performance

Enumeration-only BenchmarkDotNet comparison against native DAC and the same unoptimized cDAC at 9f06f271b8aa0cbb073b2bb6f85b16da576e6eaa. Each invocation uses a fresh enumerator over an immutable full snapshot. Activation, hashing, coverage checks, and cleanup are outside timing. This does not measure copying heap contents or writing a dump.

Windows x64 Hyper-V VM, AMD EPYC 7763, Release NativeAOT, SDK 11.0.100-rc.2.26504.105. Three launches, five warmups, thirty actual iterations per launch: 90 measured samples for each of 54 provider/workload/mode cases.

Workload Mode Native DAC (ms) cDAC before (ms) cDAC after (ms) Time reduction
SmallSimple Mini 1.640 3.930 3.914 0.4%
SmallSimple Heap 1.714 4.604 4.522 1.8%
SmallSimple Triage 2.320 4.383 3.967 9.5%
LargeSimple Mini 1.810 3.985 3.935 1.2%
LargeSimple Heap 1.966 4.721 4.432 6.1%
LargeSimple Triage 1.732 3.677 3.434 6.6%
SmallComplex Mini 3.148 9.144 7.533 17.6%
SmallComplex Heap 3.219 9.922 8.019 19.2%
SmallComplex Triage 3.382 9.303 7.416 20.3%
LargeComplex Mini 9.934 43.851 28.590 34.8%
LargeComplex Heap 10.766 44.523 30.167 32.2%
LargeComplex Triage 10.877 42.846 27.902 34.9%
CodeHeavy Mini 3.450 11.029 8.610 21.9%
CodeHeavy Heap 3.650 12.105 9.287 23.3%
CodeHeavy Triage 3.653 11.769 8.131 30.9%
DeepStacks Mini 11.283 61.365 39.276 36.0%
DeepStacks Heap 11.310 65.046 41.974 35.5%
DeepStacks Triage 12.325 59.820 38.212 36.1%

The substantive wins are in complex/stack-heavy workloads. Simple cases have small absolute differences and VM timing variability; those should not be read as established improvements. For example, SmallSimple/Mini is 3.930 +/- 0.321 ms before versus 3.914 +/- 0.401 ms after (mean +/- standard deviation). DeepStacks/Heap is 65.046 +/- 2.138 ms versus 41.974 +/- 2.866 ms.

Note

This description was generated with GitHub Copilot.

Reuse the caller context computed while checking skipped frames and clear it when advancing the managed context or processing frame/native transitions. Verify unwind lookup reuse in the existing Wasm stack-walk test.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: de3eab4e-b090-430a-8e30-6b204fb1519a
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 4 pipeline(s).
12 pipeline(s) were filtered out due to trigger conditions.
There may be pipelines that require an authorized user to comment /azp run to run.

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag
See info in area-owners.md if you want to be subscribed.

Move cached caller lookup and standard unwinding into StackWalkData. Invalidate the cache through the Context setter and GetContextForUpdate for in-place mutations, leaving interpreter handling and State unchanged.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: de3eab4e-b090-430a-8e30-6b204fb1519a
@max-charlamb

Copy link
Copy Markdown
Member Author

/ba-g unrelated infra failure

@max-charlamb
max-charlamb merged commit 3ddbf14 into dotnet:main Nov 2, 2026
94 of 98 checks passed
@max-charlamb
max-charlamb deleted the cdac-reuse-stackwalk-caller-context branch November 2, 2026 15:40
@dotnet-milestone-bot dotnet-milestone-bot Bot added this to the 12.0-preview1 milestone Nov 4, 2026
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