Skip to content

[release/11.0] Fix a trim a NAOT trim regression - #132590

Open
github-actions[bot] wants to merge 2 commits into
release/11.0from
backport/pr-132550-to-release/11.0
Open

[release/11.0] Fix a trim a NAOT trim regression#132590
github-actions[bot] wants to merge 2 commits into
release/11.0from
backport/pr-132550-to-release/11.0

Conversation

@github-actions

@github-actions github-actions Bot commented Aug 20, 2026

Copy link
Copy Markdown
Contributor

Backport of #132550 and #132576 to release/11.0.

Customer Impact

  • Customer reported
  • Found internally

These changes reduce NativeAOT application size and avoid unnecessary startup work by removing the Number static constructor and deferring the ICU-only CompareInfo search values and EncodingTable name cache until they are used.

The official size report measured:

Project Size before Size after Difference
TodosApi-linux 25,164,720 25,148,336 -16,384
TodosApi-windows 26,211,328 26,191,872 -19,456
avalonia.app-linux 18,891,856 18,863,056 -28,800
avalonia.app-windows 19,235,328 19,207,680 -27,648
hello-linux 1,266,848 1,229,840 -37,008
hello-minimal-linux 1,119,272 1,082,248 -37,024
hello-minimal-windows 824,320 765,952 -58,368
hello-windows 987,648 923,136 -64,512
kestrel-minimal-linux 5,393,152 5,376,768 -16,384
kestrel-minimal-windows 4,920,832 4,899,840 -20,992
reflection-linux 1,861,768 1,824,712 -37,056
reflection-windows 1,731,072 1,687,040 -44,032
webapiaot-linux 9,879,224 9,862,840 -16,384
webapiaot-windows 10,360,832 10,341,376 -19,456
winrt-component-minimal-windows 772,608 715,264 -57,344

Regression

  • Yes
  • No

#132550 fixes a NativeAOT size regression introduced by #131019, which added the Decimal32/64/128 transcendental coefficient tables to the data rooted by Number's static initialization. #132576 is an additional optimization found during the same investigation for two pre-existing CoreLib caches.

Testing

The combined backport passed checked CoreLib and NativeAOT CoreLib builds, a Release NativeAOT build, 61,658 System.Globalization.Tests, 14,695 System.Text.Encoding.Tests, and 77,365 System.Runtime.Tests, with zero failures. The invariant-globalization NativeAOT Hello World was also built and run at the servicing baseline, after #132550, and after both changes.

Risk

Low. Both changes only alter internal initialization and data representation, are direct backports of merged main work, and do not change public API or intended behavior. The affected CoreLib, globalization, encoding, System.Runtime, and NativeAOT surfaces were validated, including the full relevant test suites and before/after NativeAOT application builds.

Note

This pull request description was prepared with GitHub Copilot.

Moves `Number`'s primitive Decimal32/64/128 coefficient data to
RVA-backed spans and computes the remaining small structured constants
on demand. Managed caches that still require initialization are isolated
in nested holder types, so `Number` no longer has a static constructor
and unused data can be trimmed.

Formatting patterns now use switch-selected RVA byte spans rather than
managed string arrays. Direct byte handling was within benchmark noise
versus the prior implementation: currency `-1.9%`, number `-1.2%`, and
percent `+0.2%`, with unchanged allocations.

Validated CoreCLR, NativeAOT, and Mono builds and all 77,366
`System.Runtime.Tests`.

> [!NOTE]
> This pull request was created with GitHub Copilot.

---------

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@azure-pipelines

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

Backports the complete logical change from #132576.

Original commits:
- 8603450
- aa6346d
- a55f9e2
- dc72d63

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Tagging subscribers to this area: @dotnet/area-system-numerics
See info in area-owners.md if you want to be subscribed.

@tannergooding

Copy link
Copy Markdown
Member

CC. @MichalStrehovsky for the backport, which fixes the regression you identified.

-- Is getting the full numbers from https://github.com/MichalStrehovsky/rt-sz something anyone can do, or do you need to be the one to open the issue?

@MichalStrehovsky

Copy link
Copy Markdown
Member

-- Is getting the full numbers from https://github.com/MichalStrehovsky/rt-sz something anyone can do, or do you need to be the one to open the issue?

Anyone can open an issue. The only problem is with adding labels but this doesn't need labels.

I've opened one at MichalStrehovsky/rt-sz#252. I've never tried this with a non-main PR, but RC1 is not too far from main at this point so it might work.

@artl93 artl93 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Regression. Approved.

@tannergooding tannergooding changed the title [release/11.0] Remove the Number static constructor [release/11.0] Fix a trim a NAOT trim regression Aug 21, 2026
@tannergooding tannergooding added the Servicing-approved Approved for servicing release label Aug 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-System.Numerics Servicing-approved Approved for servicing release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants