Skip to content

Avoid cross-thread ArrayPool tracking in single-threaded builds - #137490

Merged
jkotas merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-single-threaded-arraypool-trimming
Nov 14, 2026
Merged

jkotas merged 1 commit into
dotnet:mainfrom
MichalStrehovsky:nativeaot-single-threaded-arraypool-trimming

Conversation

@MichalStrehovsky

Copy link
Copy Markdown
Member

Keep TLS trimming and Gen2 GC callbacks while omitting the ConditionalWeakTable registry when FEATURE_MULTITHREADING is disabled.

Keep TLS trimming and Gen2 GC callbacks while omitting the ConditionalWeakTable registry when FEATURE_MULTITHREADING is disabled.

Co-authored-by: Copilot <[email protected]>
Copilot-Session: a12afcbf-930f-4101-b0ed-bd4a35548d7e
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to 'arch-wasm': @lewing, @pavelsavara
See info in area-owners.md if you want to be subscribed.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 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: @dotnet/area-system-buffers
See info in area-owners.md if you want to be subscribed.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The new branch lacks regression coverage on single-threaded browser/WASI builds because existing tests require RemoteExecutor; an in-process test must verify eventual TLS eviction with logging both disabled and enabled.

1 open issue
What changed in this PR

This PR removes cross-thread tracking from SharedArrayPool<T> in single-threaded builds while retaining thread-local buffer trimming and Gen2 GC callbacks.

Changes:

  • Guard the ConditionalWeakTable registry and registration with FEATURE_MULTITHREADING.
  • Trim thread-local buckets directly when multithreading is disabled, preserving logging behavior.
  • Keep GC callback registration unchanged.
File Description
src/​libraries/​System.Private.CoreLib/​src/​System/​Buffers/​SharedArrayPool.cs Conditionally omit cross-thread tracking and trim local buckets directly in single-threaded builds.

Review effort: Balanced

@jkotas

jkotas commented Nov 14, 2026

Copy link
Copy Markdown
Member

/ba-g known failure #137525

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

arch-wasm WebAssembly architecture area-System.Buffers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants