Skip to content

Use spans to reduce allocations in Maps - #40785

Merged
kubaflo merged 2 commits into
mainfrom
simonrozsival-net12-maps-spans
Nov 30, 2026
Merged

kubaflo merged 2 commits into
mainfrom
simonrozsival-net12-maps-spans

Conversation

@simonrozsival

@simonrozsival simonrozsival commented Nov 28, 2026 •

Copy link
Copy Markdown
Member

Agent assessment

Self-reported assessment, not an independent review.

Assessed revision: cc5e8b30c6a4a9e4b9c7ec8fe4802536ef6fb4b7

Dimension Assessment Rationale
Change confidence 7.5/10 ↑ Clean rebase onto Essentials 6f75ab472d; diff is the same five Maps files.
↑ On net12.0: 200/200 Map-filtered Controls.Core tests and 19/19 converter tests pass; benchmark project builds with 0 warnings; format check clean.
↓ net12 Android MapHandler not compiled locally (NETSDK1139: the installed Android workload targets net11); relies on CI.
↓ Benchmark numbers are historical and not rerun; ConvertTo change not benchmarked; CI for this head not inspected.

Note

Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

This is the final Maps layer of the .NET 12 spans stack. Its immediate base is simonrozsival-net12-essentials-spans (#40783), rebased onto that branch's head 6f75ab472d03f5dc70154418240bf2338f098b65. GitHub native stack registration is handled separately.

Description of Change

Important

Reviewers: please weigh the risk of breaking external consumers and dependencies that require netstandard before merging. That compatibility evaluation has not been done in this PR.

  • Parse MapSpan coordinates through stack-allocated ranges and span-based numeric parsing instead of allocating a split string array and substrings. Exactly-four-part validation, whitespace handling, invariant-culture parsing and exceptions are unchanged.
  • Build Android polygon/polyline point lists with a pre-sized indexed loop instead of LINQ projection and list growth.
  • Format ConvertTo output with a single string.Create(CultureInfo.InvariantCulture, ...) interpolation instead of four separate ToString(CultureInfo.InvariantCulture) calls and two concatenated strings. Output order, separators, invariant numeric formatting and NotSupportedException for non-MapSpan values are unchanged.
  • Add malformed-input, exact-output, non-invariant-culture and invalid-value converter tests. Add the Maps converter benchmark and project reference, keeping the Essentials benchmarks from the base.

Only these five files differ from the immediate base:

  • src/Core/maps/src/Converters/MapSpanTypeConverter.cs
  • src/Core/maps/src/Handlers/Map/MapHandler.Android.cs
  • src/Controls/tests/Core.UnitTests/MapSpanTypeConverterTests.cs
  • src/Core/tests/Benchmarks/Benchmarks/EssentialsMapsBenchmarker.cs (Maps import, field and method only)
  • src/Core/tests/Benchmarks/Core.Benchmarks.csproj (Maps project reference only)

Benchmark evidence (historical, from the earlier combined-source run)

Operation Before time After time Before allocated After allocated
MapSpanTypeConverter.ConvertFrom 166.2 ns 118.4 ns 488 B 176 B

These figures are historical. They come from an earlier benchmark of the combined source branch (commit 04fb9f8a71) and were not rerun for this PR or this head. That run's exact runtime was not preserved, so no .NET 12 benchmark runtime is claimed. Short-run timings are noisy, and this split layer was not measured on its own. There is no benchmark evidence for the Android polygon/polyline change, and the ConvertTo formatting change was not benchmarked.

Local validation (head cc5e8b30c6)

Local SDK: 12.0.100-alpha.1.26551.101. Portable output TFM: net12.0. Installed workloads: android, ios and maccatalyst, all on net11 (rc.2) manifests.

Exact command Result
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter 'FullyQualifiedName~Map' -v:q Passed: 200 tests, 0 failed, 0 skipped (net12.0).
dotnet test src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false --filter 'FullyQualifiedName~MapSpanTypeConverterTests' -v:q Passed: 19 tests, 0 failed (net12.0).
dotnet build src/Core/tests/Benchmarks/Core.Benchmarks.csproj -p:IncludeAndroidTargetFrameworks=false -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -v:q Passed: 0 warnings, 0 errors. Benchmarks were not executed.
dotnet build src/Core/maps/src/Maps.csproj -f net12.0-android -p:IncludeIosTargetFrameworks=false -p:IncludeMacCatalystTargetFrameworks=false -v:q Blocked: NETSDK1139 (android not recognized for net12.0-android37.0). MapHandler.Android.cs was not compiled locally, so CI must cover it.
dotnet format whitespace <project> --no-restore --verify-no-changes --include <changed .cs files> --verbosity quiet (Maps, Controls.Core.UnitTests and Core.Benchmarks projects) Passed (exit 0) for all three.
git diff --quiet 94138e41fb HEAD -- <Maps source/test files> Passed: the rebase left the Maps converter, handler and test content unchanged.

I did not inspect CI for this head.

Issues Fixed

N/A — performance work, not a bug fix.

@azure-pipelines

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

@simonrozsival simonrozsival changed the title [net12] Use spans to reduce allocations in Maps Use spans to reduce allocations in Maps Nov 28, 2026
@kubaflo

kubaflo commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

/review expert-review

@kubaflo

This comment has been minimized.

@github-actions

This comment has been minimized.

@kubaflo

kubaflo commented Nov 29, 2026

Copy link
Copy Markdown
Contributor

/review expert-review

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Selected Tests

@kubaflo — AI-selected UI tests and device tests for commit 94138e41.

Result NOT QUEUED Platforms none Tests 0 UI, 0 device Commit 94138e41


🧪 Test selection — click to expand
Suite Result Selected Build
UI tests ❌ not queued none —
Device tests ❌ not queued none —
🧪 UI tests — nothing to run

❌ Could not queue maui-pr-uitests: No AI model produced a test selection, so nothing was queued. Comment /review run-tests again, or use /azp run maui-pr-uitests for the full suite.

🧪 Running — nothing

No UI tests run for this PR.

🧪 Device tests — nothing to run

❌ Could not queue maui-pr-devicetests: No AI model produced a test selection, so nothing was queued. Comment /review run-tests again, or use /azp run maui-pr-devicetests for the full suite.

🧪 Running — nothing

No device tests run for this PR.

⏭️ Skipped — what neither suite runs

UI tests — 77 categories, 4 platforms

Platforms not run: Android, iOS, MacCatalyst, Windows

Each skipped platform and category is listed as a maui-pr-uitests (skipped) … status on this commit. Use /azp run maui-pr-uitests for the full suite.

Device tests — 105 categories, 4 platforms

Platforms not run: Android, iOS, MacCatalyst, Windows

Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.

🤖 Why these tests — AI rationale

UI tests

No rationale provided.

Device tests

No rationale provided.

Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.

@simonrozsival
simonrozsival force-pushed the simonrozsival-net12-maps-spans branch from 94138e4 to cc5e8b3 Compare November 30, 2026 12:16
@github-actions

This comment has been minimized.

@simonrozsival
simonrozsival marked this pull request as ready for review November 30, 2026 12:17
Copilot AI balanced review requested due to automatic review settings November 30, 2026 12:17

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.

🔵 Needs a closer look

The prerequisite stack drops netstandard support without evaluating external-consumer compatibility, requiring maintainer review, and compilation of the changed Android handler remains unverified.

No open issues 🎉

What changed in this PR

This PR completes the Maps layer of the .NET 12 span-allocation work, building on the Essentials changes in #40783.

Changes:

  • Replaces string splitting with span-based MapSpan parsing and uses invariant-culture interpolation for formatting.
  • Replaces Android polygon/polyline LINQ projections with pre-sized, indexed list construction.
  • Expands converter tests and adds a Maps parsing benchmark.

Benchmark measurements are historical; Android compilation was not validated locally.

File Description
src/​Core/​tests/​Benchmarks/​Core.Benchmarks.csproj Adds the Maps project reference for benchmarking.
src/​Core/​tests/​Benchmarks/​Benchmarks/​EssentialsMapsBenchmarker.cs Adds a MapSpanTypeConverter.ConvertFrom benchmark.
src/​Core/​maps/​src/​Handlers/​Map/​MapHandler.Android.cs Shares pre-sized point-list construction for polygons and polylines.
src/​Core/​maps/​src/​Converters/​MapSpanTypeConverter.cs Reduces parsing and formatting allocations.
src/​Controls/​tests/​Core.UnitTests/​MapSpanTypeConverterTests.cs Covers malformed input, exact formatting, culture independence, and invalid values.

Review effort: Balanced

@kubaflo
kubaflo force-pushed the simonrozsival-net12-maps-spans branch from cc5e8b3 to c3dd4cd Compare November 30, 2026 12:43
Copilot AI balanced review requested due to automatic review settings November 30, 2026 12:43
@kubaflo
kubaflo force-pushed the simonrozsival-net12-maps-spans branch 3 times, most recently from 3d81afb to da63daf Compare November 30, 2026 12:46

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.

🔵 Needs a closer look

Removing netstandard support leaves external-consumer compatibility unevaluated and requires maintainer judgment, while the changed Android handler lacks build and device validation.

No open issues 🎉

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 30, 2026 12:47
@kubaflo
kubaflo force-pushed the simonrozsival-net12-maps-spans branch from da63daf to 153648e Compare November 30, 2026 12:47
@kubaflo
kubaflo force-pushed the simonrozsival-net12-maps-spans branch from 153648e to 99d0fbe Compare November 30, 2026 12:49
Base automatically changed from simonrozsival-net12-essentials-spans to main November 30, 2026 12:50
simonrozsival and others added 2 commits November 30, 2026 13:50
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo force-pushed the simonrozsival-net12-maps-spans branch from 99d0fbe to e273583 Compare November 30, 2026 12:50
@kubaflo
kubaflo merged commit 6e2e09e into main Nov 30, 2026
4 of 5 checks passed

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.

🔵 Needs a closer look

The prerequisite stack’s netstandard removal leaves external-consumer compatibility unassessed, requiring maintainer evaluation, while current-head Android compilation remains unverified.

No open issues 🎉

Review effort: Balanced

@kubaflo
kubaflo deleted the simonrozsival-net12-maps-spans branch November 30, 2026 12:51
Copilot AI balanced review requested due to automatic review settings November 30, 2026 12:51

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.

🔵 Needs a closer look

The prerequisite .NET 12 stack’s removal of netstandard support still requires external-consumer compatibility evaluation, and the changed Android handler lacks confirmed build and runtime validation.

No open issues 🎉

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants