-
Notifications
You must be signed in to change notification settings - Fork 5.3k
[browser][ST] test trimming of System.Collections.Concurrent #123330
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
Conversation
43bc33f to
e4919ed
Compare
|
Do you have any numbers for how much this saves for user apps? ConcurrentDictionary is used pretty frequently for performance reasons. It is not practical to ifdef out every use of it. If we are not happy about its footprint for single threaded wasm, it may be better to provide an alternative lighter weight implementation instead of trying to ifdef out every use. cc @stephentoub |
I would like to see number for a Blazor app. (total size / bytes saved by this change)
Ifdefs like this tend to keep growing to the point of being non-sustainable.
That's fine with me. Queue is used a lot less frequently and ThreadPool has a bunch of ifdefs for single-threaded wasm, so one more does not sound like a problem. |
|
I agree if there's a need for something like this, we should instead just have alternate impls of those data structures for the single threaded wasm use. Could be as simple as the public API shimming to a wrapped dictionary/queue. |
OK, I reverted the corelib changes and this is only trimming test now |
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 adds a trimming test to verify that System.Collections.Concurrent types are not included in trimmed single-threaded Browser runtime builds, reducing download size. The test validates that the CoreLib avoids dependencies on concurrent collections when threads are not enabled.
Changes:
- Adds a new trimming test that checks concurrent collection types are trimmed from Browser WASM builds
- Conditionally includes the test only for Browser targets without threading enabled
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| System.Runtime.TrimmingTests.proj | Adds conditional inclusion of the new test for single-threaded Browser targets |
| BrowserDoesNotIncludeConcurrentTypes.cs | New test file that verifies concurrent collection types are trimmed from the assembly |
...tem.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs
Outdated
Show resolved
Hide resolved
...tem.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs
Outdated
Show resolved
Hide resolved
...tem.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs
Outdated
Show resolved
Hide resolved
...tem.Runtime/tests/System.Runtime.Tests/TrimmingTests/BrowserDoesNotIncludeConcurrentTypes.cs
Show resolved
Hide resolved
…ngTests/BrowserDoesNotIncludeConcurrentTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
…ngTests/BrowserDoesNotIncludeConcurrentTypes.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
Tagging subscribers to this area: @dotnet/area-system-collections |
jkotas
left a comment
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.
(Make sure that the commit description matches the final PR content when merging.)


For single-threaded Browser runtime we already
ConcurrentQueueinThreadPoolWorkQueueSystem.Collections.Concurrentassembly in the CoreLibSystem.Runtime.Tests/TrimmingTests/DoesntIncludeConcurentTypes.csSystem.Collections.Concurrent