[Draft] Add generated C# full-generation benchmarks#10885
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit 59eb312.
commit: |
|
No changes needing a change description found. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Network post-processing performance experiment resultsDocumenting the current experiment state before switching back to the Network MPG migration work. Network generator-only timingAll runs used the saved Network generator inputs from
Artifacts: Bounded parallelism follow-upI also tried an env-var-gated bounded document-processing experiment (
Artifacts: ConclusionThis PR is useful as an experiment, but the manual reducer approach is not currently a Network performance improvement. The bounded-parallelism experiment was removed from the working tree after it failed to beat Recommended next direction is deeper phase/document-size instrumentation around Roslyn workspace post-processing, then target reducing the number or size of documents that go through semantic simplification rather than replacing Roslyn simplification wholesale. |
|
Latest shadow-map replacement results from local BenchmarkDotNet runs. Correctness Shadow ComparisonReplacement mode still compares the provider/custom-code hybrid candidates against the Roslyn candidates before using them. This is for Full-Generation BenchmarkBenchmark command shape: DOTNET_ROOT="$HOME/.dotnet" PATH="$HOME/.dotnet:$PATH" \
dotnet run --project packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/perf/Microsoft.TypeSpec.Generator.Tests.Perf.csproj \
-c Release --framework net10.0 --filter "*FullGenerationBenchmark*"Replacement mode additionally used: TYPESPEC_PROVIDER_REFERENCE_MAP_SHADOW=true
TYPESPEC_PROVIDER_REFERENCE_MAP_USE_SHADOW=true
TYPESPEC_PROVIDER_REFERENCE_MAP_SHADOW_DIR="/tmp/typespec-provider-reference-map-shadow"
Approximate improvement: InterpretationThe hybrid provider/custom-code map is now exact for Next step: create a clean PR from latest |
…tion-experiment # Conflicts: # packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator.ClientModel/src/Providers/MrwSerializationTypeDefinition.cs # packages/http-client-csharp/generator/Microsoft.TypeSpec.Generator/src/PostProcessing/GeneratedCodeWorkspace.cs
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
You can try these changes here
|
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… lookup Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Summary
Benchmark/profiling PR for generated C# full generation and post-processing performance. This PR carries the benchmark harness plus the production-shaped hybrid provider reference-map logic from #10976 so we can measure it against the Roslyn reference-map path.
What Changed
Sample-TypeSpec.PostProcessAsync(),GetGeneratedFilesAsync(), and file writes._typesToKeepbehavior;Latest Benchmark Data
Latest data from benchmark PR #10885 after porting the current #10976 hybrid analyzer changes (including generated body invocation edges and base-preserved reachability).
Benchmark output root:
/tmp/typespec-final-hybrid-bench-20260624-0943.Full-generation BenchmarkDotNet, averaged across 3 local runs:
895.8 ms67.78 MB859.9 ms57.75 MBApproximate full-generation improvement:
Focused profile data, using 72 Roslyn-mode and 72 provider-mode invocations from the same runs (median):
357.2 ms23.70 MB263.2 ms17.83 MB0.79 ms0.06 MBApproximate focused reference-map improvement:
Profile notes:
POSTPROCESSING_BENCHMARK_PROFILE_STEPS=trueon the full-generation benchmark so both paths run against realTypeProvideroutput.PostProcessor.Internalize.BuildPublicReferenceMapAsyncandPostProcessor.Remove.BuildAllReferenceMapAsync.Generation.ProviderReferenceMapShadowAnalysis,PostProcessor.Internalize.UseShadowCandidates,PostProcessor.Internalize.UseShadowPublicizeCandidates,PostProcessor.Remove.UseShadowCandidates, andPostProcessor.Remove.BuildShadowReferencedSet..NET 10.0.9, Ubuntu 26.04, AMD EPYC 7763.How To Run
Latest Data
Latest local run: 3 BenchmarkDotNet runs after removing stale generated-file scanning and replacing it with current-generation roots/edges, commit
32840a556. Artifacts:/tmp/typespec-current-generated-roots-bench/run-{1,2,3}.Full-generation BenchmarkDotNet
833.5,977.7,923.0 ms911.4 ms67.75 MB836.4,792.4,782.7 ms803.8 ms52.30 MBApproximate full-generation improvement:
Focused reference-map profile
Profile data below uses all 72 Roslyn-mode and 72 provider-mode invocations across the same three runs, with trimmed averages.
437.7 ms23.74 MB243.3 ms12.33 MB0.88 msFocused reference-map replacement improvement:
Validation
npm run build:generatorhttp/typehttp/documentationhttp/parameters/collection-formathttp/payload/multipartnpm run formatnpm run lintConclusion
The previous final-parity benchmark regressed because it scanned stale
src/Generatedfiles and over-rooted old public generated declarations. The latest version removes that stale scan and fixes the actual current-generation gaps, restoring both correctness on targeted scenarios and an end-to-end full-generation performance win.Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com
Latest Safe Provider-Map Optimization (2026-06-24)
Pushed safe optimization commits:
88bea57587b3c0f1e5Changes:
SymbolFinder.FindReferencesAsynchelper lookup from generated-body dependency discovery.Safe two-pass focused profile aggregate (
/tmp/typespec-provider-map-safe-final-20260624-1320,/tmp/typespec-provider-map-safe-final2-20260624-1320) compared with the previous hotspot baseline (/tmp/typespec-provider-map-hotspots-20260624-1320):231.5 ms,18.03 MB188.8 ms,7.89 MB~18.4%faster,~56.2%less allocation231.3 ms,17.98 MB188.0 ms,7.83 MB~18.7%faster,~56.4%less allocationValidation after the safe correction:
npm run build:generatorpwsh ./eng/scripts/Generate.ps1 -filter Sample-TypeSpecwith no checked-in generated diffsLatest 3-Run Benchmark Data (2026-06-24 14:03 UTC)
Benchmark branch:
mtg-manual-name-reduction-experimentat7b3c0f1e5. Artifacts:/tmp/typespec-latest-safe-bench-20260624-1403/run-{1,2,3}.Full-generation BenchmarkDotNet
1295.0,1029.8,1633.4 ms1319.4 ms67.52 MB1008.0,785.1,795.0 ms862.7 ms47.95 MBApproximate full-generation improvement:
Focused reference-map profile
Profile data uses 71 Roslyn-mode and 71 provider-mode invocations from the same three runs (median):
429.7 ms23.65 MB198.7 ms7.87 MB197.0 ms7.81 MB0.98 ms0.06 MBApproximate focused reference-map replacement improvement:
Latest Helper-Fix Benchmark Data (2026-06-24 14:36 UTC)
Benchmark branch:
mtg-manual-name-reduction-experimentatb14b1f282. Artifacts:/tmp/typespec-helper-fix-bench-20260624-1436/run-{1,2,3}. This includes the CI helper-root fix that explicitly preserves generatedClientUriBuilder,ClientPipelineExtensions, andCancellationTokenExtensionswithout restoring the broad RoslynSymbolFinderhelper lookup.Full-generation BenchmarkDotNet
1025.7,881.6,1007.9 ms971.7 ms67.64 MB809.8,693.8,842.7 ms782.1 ms48.12 MBApproximate full-generation improvement:
Focused reference-map profile
Profile data uses 72 Roslyn-mode and 72 provider-mode invocations from the same three runs (median):
349.0 ms23.57 MB172.6 ms7.88 MB171.3 ms7.82 MB0.80 ms0.06 MBApproximate focused reference-map replacement improvement: