Skip to content

[TrimmableTypeMap] Parallelize JCW source generation #11490

Open

Description

@simonrozsival

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.

Activity

  1. added
    needs-triage
    on May 25, 2026
  2. removed
    needs-triage
    on May 25, 2026
  3. added this to the .NET 11 milestone on May 25, 2026
  4. added
    copilot
    on May 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    copilottrimmable-type-map

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions