dotnet / runtime

.NET is a cross-platform runtime for cloud, mobile, desktop, and IoT apps.
https://docs.microsoft.com/dotnet/core/
MIT License
14.95k stars 4.65k forks source link

R2R Build perf: consider parallelizing `RunReadyToRunCompiler` in `_CreateR2RImages` #93364

Open rainersigwald opened 11 months ago

rainersigwald commented 11 months ago

I was looking through a build binlog and noticed that there is target batching going on in _CreateR2RImages:

https://github.com/dotnet/runtime/blob/21c52fa8ce11fab02d4b166718f6165553c6977c/src/tasks/Crossgen2Tasks/Microsoft.NET.CrossGen.targets#L465-L467

This serializes the invocation of crossgen2 for each reference. It seems likely that invoking many copies in parallel is likely to reduce build wall-clock time, especially on many-core dev desktops.

Ideally, the task would get all the inputs at once and use MSBuild's throttling mechanisms (RequestCores/ReleaseCores) to avoid oversubscribing the machine if many projects are running R2R at once.

Feel free to reach out to me or the MSBuild team with any questions.

SingleAccretion commented 11 months ago

It seems likely that invoking many copies in parallel is likely to reduce build wall-clock time, especially on many-core dev desktops.

CG2 utilizes internal parallelism so that is not necessarily the case.