Part of #10958.
JcwJavaSourceGenerator.GenerateContent(...) currently generates Java Callable Wrapper source content sequentially, even though each Java peer's .java file is independent. PR #10924 measurements in #10958 showed JCW generation as the dominant cold-build phase, so this is a good contained optimization candidate.
Current locations
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.cs
GenerateContent(...) loops over all peers serially.
src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.cs
GenerateJcwJavaSources(...) calls GenerateContent(...) after filtering peers.
src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.cs
WriteJavaSourcesToDisk(...) writes the generated source list using Files.CopyIfStreamChanged(...).
Suggested implementation
- Generate source content in parallel across peers.
- Preserve deterministic output ordering so task outputs and tests remain stable.
- Avoid sharing mutable
TextWriter/generator state across workers unless it is proven thread-safe; the simplest approach is one local StringWriter per peer.
- Keep the existing content-comparison write behavior.
Acceptance criteria
- JCW source generation uses parallelism for independent peers.
- Generated file paths/content remain deterministic and behavior-compatible with existing tests.
- Existing trimmable typemap tests pass; add a focused test if ordering or thread-safety needs coverage.
Part of #10958.
JcwJavaSourceGenerator.GenerateContent(...)currently generates Java Callable Wrapper source content sequentially, even though each Java peer's.javafile is independent. PR #10924 measurements in #10958 showed JCW generation as the dominant cold-build phase, so this is a good contained optimization candidate.Current locations
src/Microsoft.Android.Sdk.TrimmableTypeMap/Generator/JcwJavaSourceGenerator.csGenerateContent(...)loops over all peers serially.src/Microsoft.Android.Sdk.TrimmableTypeMap/TrimmableTypeMapGenerator.csGenerateJcwJavaSources(...)callsGenerateContent(...)after filtering peers.src/Xamarin.Android.Build.Tasks/Tasks/GenerateTrimmableTypeMap.csWriteJavaSourcesToDisk(...)writes the generated source list usingFiles.CopyIfStreamChanged(...).Suggested implementation
TextWriter/generator state across workers unless it is proven thread-safe; the simplest approach is one localStringWriterper peer.Acceptance criteria