Repository navigation
Initialize region mappings from UTF-8 constant data - #135799
Closed
davidwrighton wants to merge 1 commit into
Closed
davidwrighton wants to merge 1 commit into
davidwrighton wants to merge 1 commit into
Conversation
Replace the CultureData region dictionary initializer with a delimited UTF-8 constant and span-based parsing loop. Preserve all mappings and lazy caching, and strengthen the existing region-list test. Co-authored-by: Copilot <[email protected]>
|
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. |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-globalization |
Member
Author
|
I do not intend to push to merge this until we have a better indication on size improvement. |
tarekgh
reviewed
Oct 14, 2026
Contributor
There was a problem hiding this comment.
🔵 Needs a closer look
Current-branch runtime validation remains outstanding, and the reported size-versus-startup regression tradeoff requires maintainer judgment.
0 open findings
What changed in this PR
Replaces CoreLib’s region dictionary initializer with compact UTF-8 data to reduce generated initialization code.
Changes:
- Parses 255 region mappings while preserving case-insensitive lookup and lazy caching.
- Strengthens tests for entry count, comparer, representative mappings, and lowercase lookup.
| File | Description |
|---|---|
| src/libraries/System.Runtime/tests/System.Globalization.Tests/System/Globalization/RegionInfoTests.cs | Adds mapping and lookup assertions. |
| src/libraries/System.Private.CoreLib/src/System/Globalization/CultureData.cs | Initializes region mappings from delimited UTF-8 data. |
🧠 Review effort: Balanced
This was referenced Oct 15, 2026
Closed
tarekgh
approved these changes
Nov 11, 2026
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.
Description
Extract the independent region-table change from #135553 onto current
main.Replace the 255-entry
CultureData.RegionNamesdictionary initializer with a delimited UTF-8 constant and a span-based parsing loop. Preserve the complete mapping, ordinal-ignore-case lookup, invariant-region empty value, and lazy caching. Strengthen the existing region-list test with count, comparer, representative mapping, and lowercase-lookup assertions.Source commit:
3b299c230fc948100a0cf794d445180f1ad35c7b. This PR does not include two-phase compilation, direct calls, or the prolog/frame-identity changes.Historical measurements and tradeoffs
These matched before/after measurements were collected on the original development branch, not on this newly extracted/rebased PR. Brotli used quality 11 and window 22.
The retail Brotli result is effectively neutral; the composite benefited from reduced generated initialization code. These image-dependent historical results are not a guarantee of the same savings on current main.
Cold initialization regresses: the historical native BenchmarkDotNet ShortRun, with
DOTNET_ReadyToRun=0, measured the uncached dictionary construction at 5.259 us before versus 16.774 us after (3.20x), allocating 8,336 versus 24,784 bytes (2.97x). Cached access measured 5.618 versus 4.783 ns, but that tiny, short-run timing is not evidence of a reliable throughput improvement. This draft deliberately exposes the size/startup-allocation tradeoff for review.Validation
git diff --check upstream/main...split/region-utf8— passed.libclrinterpreter.sowas missing from the platform manifest. The subsequent baseline retry was stopped when the user requested no more builds.This remains a draft; runtime validation on the independent branch is outstanding.
Note
This PR was prepared with GitHub Copilot.