[TrimmableTypeMap] Parallelize JCW source generation
- Dominant language
- C#
- Stars
- 2.1k
- Forks
- 579
- Avg merge
- 1d 20h
- Merged PRs (30d)
- 257
Description
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.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.