-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser][CoreCLR] Trimming feature System.Diagnostics.StackTrace.IsLineNumberSupported #123429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[browser][CoreCLR] Trimming feature System.Diagnostics.StackTrace.IsLineNumberSupported #123429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR optimizes browser/WASM builds by disabling stack trace file information (filename, line number, column number) collection for the TARGET_BROWSER platform. This saves approximately 214KB of uncompressed IL from hello world applications.
Changes:
- Guard file info population code in
StackFrameHelper.InitializeSourceInfowith#if !TARGET_BROWSER - Guard static reentrancy tracking fields used only for file info processing
- Guard file info field assignments in
StackFrameconstructors - Add CA1822 pragma suppression for
InitializeSourceInfo(needed because the method doesn't use instance state on browser)
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrameHelper.cs |
Guards file info processing logic and reentrancy tracking with #if !TARGET_BROWSER, adds CA1822 suppression |
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs |
Guards file info field assignments in constructor and BuildStackFrame method with #if !TARGET_BROWSER |
|
We can eventually hide this behind some feature flag. So that in debug build, we would have full fidelity stack trace with line numbers. There is Could the same flag be used here ? @jkotas |
|
Tagging subscribers to 'size-reduction': @eerhardt, @SamMonoRT, @marek-safar |
src/coreclr/System.Private.CoreLib/src/System/Diagnostics/StackFrame.CoreCLR.cs
Outdated
Show resolved
Hide resolved
|
Is the stack trace line number support unconditionally disabled in Mono Browser today? Trying to understand whether we need extra work to get CoreCLR to parity with Mono Browser.
The existing msbuild property that does the same thing is |
Not 100% sure, but I don't think we do anything special. If runtime/src/mono/mono/metadata/mono-debug.c Line 799 in 46c884e
I was wondering the same thing. And perhaps apply it in https://github.com/dotnet/runtime/blob/5dd95537d5faa20e8baed719e9f5f18d5f29494c/src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs instead of the CoreCLR specific file. |
Mono doesn't use
214KB is 4% of mono wasm hello world download size
Thanks! |
I think from the BCL perspective it's still passing that it wants line numbers into an icall. I suspect we aren't getting them as a byproduct as opposed to doing something explicit for wasm. |
|
runtime/src/mono/mono/mini/mini-exceptions.c Line 1456 in ebae784
runtime/src/mono/mono/metadata/mono-debug.c Lines 789 to 800 in ebae784
|
|
It seems to me that Mono functionality depends on debugger native module being linked in and also on PDB information being available. |
What does it do in debug builds? |
|
|
So this PR will regress debug builds and improve size of release builds. I am not sure whether it is an improvement |
No this PR (in current shape) was conversation opener. If we introduce that |
src/libraries/System.Private.CoreLib/src/System/Diagnostics/StackTrace.cs
Outdated
Show resolved
Hide resolved
...nuget/Microsoft.NET.Sdk.WebAssembly.Pack/build/Microsoft.NET.Sdk.WebAssembly.Browser.targets
Outdated
Show resolved
Hide resolved
|
/ba-g CI timeouts |


[FeatureSwitchDefinition("System.Diagnostics.StackTrace.IsLineNumberSupported")]<StackTraceLineNumberSupport>false</StackTraceLineNumberSupport>saves 214KB of uncompressed IL from hello world