[net11.0] Cache R2R image when only user assemblies are changed#24735
[net11.0] Cache R2R image when only user assemblies are changed#24735kotlarmilos wants to merge 3 commits intonet11.0from
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| <WriteLinesToFile | ||
| File="$(_TrimHashesFile)" | ||
| Lines="@(_TrimmedDllsWithHash->'%(Identity)|%(FileHash)')" | ||
| Overwrite="true" /> |
There was a problem hiding this comment.
There might be a simpler way to implement this:
- After selecting which assemblies to add to the R2R image (say in the
_SelectR2RAssembliestarget), compute the hash contents - Write these hash contents to the hash file with the
WriteLinesToFiletask, but also set theWriteOnlyWhenDifferent="true"property on the task. - Use the timestamp of the hash file to determine whether R2R needs to run or not. One (somewhat hacky) way of doing this would be to set the timestamp of all the R2R assemblies to the timestamp of the hash file.
There was a problem hiding this comment.
Thanks, updated. One thing - touching the input doesn’t scale well (it took ~4s for the MAUI template), so I introduced a .trigger file that is always updated. It checks whether the hash has been written and if it has, it touch the output instead.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #93c4b82] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #93c4b82] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
✅ [CI Build #93c4b82] Build passed (Build macOS tests) ✅Pipeline on Agent |
💻 [CI Build #93c4b82] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [CI Build #93c4b82] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [CI Build #93c4b82] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
🚀 [CI Build #93c4b82] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 117 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |
Desription
In non-Release R2R composite mode when user assemblies change, they are treated as entry points and used as inputs to the _CreateR2RImages target. As a result the ILLink task always writes new assemblies to disk, which forces the _CreateR2RImages task to execute every time.
The caching mechanism works by computing a content-based hash of non-user assemblies, then writing this hash to an intermediate file. A .trigger file is touched on every build to track when the hash was last computed. If the hash file is older than the trigger file (meaning the hash didn't change), the R2R outputs are touched to satisfy msbuild incremental build checks, skipping the R2R compilation step.
With this change, incremental build time for user assembly changes is reduced from ~39s to ~26s.