Repository navigation
[cDAC] Avoid allocating stack contexts for output - #136934
Draft
max-charlamb wants to merge 1 commit into
Draft
max-charlamb wants to merge 1 commit into
max-charlamb wants to merge 1 commit into
Conversation
Return stack context snapshots as read-only spans so output callers can copy directly without first allocating a temporary byte array. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: de3eab4e-b090-430a-8e30-6b204fb1519a
|
Azure Pipelines: Successfully started running 5 pipeline(s). 10 pipeline(s) were filtered out due to trigger conditions. There may be pipelines that require an authorized user to comment /azp run to run. |
Contributor
|
Tagging subscribers to this area: @steveisok, @tommcdon, @dotnet/dotnet-diag |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Return retained stack-context snapshots as
ReadOnlySpan<byte>instead of allocating a newbyte[]for every output request.This changes only the context-output APIs:
IStackWalk.GetRawContextreturns a read-only view of the frame's retained context snapshot.IPlatformAgnosticContext.GetBytesreturns a read-only view over the serialized platform context.The span remains backed by the context snapshot owned by the stack frame handle. Advancing the walk does not mutate that retained snapshot.
Performance
Measured frozen NativeAOT readers with provider identities reversed between two passes. Each pass used 3 launches with 30 observations per case, with no outlier removal. The primary run retained 2,520 observations across 14 timing cases.
A separate cold-walk confirmation used two more reversed passes and 720 additional observations:
The change removes one temporary 1,232-byte array for each AMD64 context output. Dump-enumeration timing does not directly exercise the migrated output APIs, and shared-host timing differences are not guaranteed gains.
Correctness checks confirmed identical serialized bytes for all seven platform context layouts, exact stack parity across 18 native/baseline/current cases, identical Mini/Heap/Triage dump ranges and updates, and matching context bytes for six real-dump cases in cold and warm states.
Testing
dotnet test src\native\managed\cdac\tests\UnitTests\Microsoft.Diagnostics.DataContractReader.Tests.csproj -c Release --no-restore -m:1 -p:BuildInParallel=false -p:RuntimeConfiguration=Release -p:LibrariesConfiguration=Release-- passed, 3,914 tests.dotnet test src\native\managed\cdac\tests\DumpTests\Microsoft.Diagnostics.DataContractReader.DumpTests.csproj -c Release --no-restore -m:1 -p:BuildInParallel=false -p:RuntimeConfiguration=Release -p:LibrariesConfiguration=Release -p:SkipDumpVersions=net10.0 --filter 'FullyQualifiedName~StackWalkDumpTests|FullyQualifiedName~IXCLRDataFrameDumpTests|FullyQualifiedName~DacDbiStackWalkDumpTests'-- passed, 63 tests with 19 expected skips.Note
This pull request description was generated with GitHub Copilot.