Summary
After a domain reload that follows a script compile, HotReloadEditorStartup.CaptureOnFirstUpdateTick runs HotReloadSourceSnapshotter.CaptureAfterDomainReload() synchronously on the main thread. In my project it takes about 1.9–2.3 s, which is added to every script compile even when hot reload is not used.
Environment
- uloop package 3.12.0 (also observed on 3.6.2), dispatcher 3.8.0, runner 3.6.2
- Unity 6000.6.4f1, Windows 11
- Storage: NVMe SSD
- Project: 2,599 scripts; the edited assembly (
Main) has 825 source files
How to reproduce
- In a project with a large assembly (several hundred source files), enable editor profiling (
ProfilerDriver.profileEditor = true; ProfilerDriver.enabled = true;).
- Change one line in a method body of that assembly and run
uloop compile.
- In the first frame after the domain reload, look at
EditorApplication.update: HotReloadEditorStartup.<Initialize>g__CaptureOnFirstUpdateTick.
Measurement
| Sample |
Time |
EditorApplication.update: HotReloadEditorStartup.<Initialize>g__CaptureOnFirstUpdateTick |
1,916 ms (3.12.0, Release code optimization) / 2,272 ms (3.6.2, Debug code optimization) |
- Each compile writes a new
Library/UloopHotReload/SourceSnapshot/Main-<MVID>/ with 781 files (3.3 MB).
- For reference, the whole
uloop compile takes about 17.5 s (Bee build ~4.9 s, domain reload ~5.1 s), so this capture is a noticeable part of the wait.
Suggestion
I understand from #3195 that the first-update hook was kept so a capture still happens early when no request comes, and that the pause point path reads the snapshot without going through the new gate. With that in mind, one of these might be worth considering:
- make the eager capture opt-in (or skippable), so projects that do not use hot reload or pause points do not pay for it on every compile; or
- run the file copy off the main thread, with the gate waiting for it to finish before a snapshot is read. I have not checked whether every step of the capture can run off the main thread.
Summary
After a domain reload that follows a script compile,
HotReloadEditorStartup.CaptureOnFirstUpdateTickrunsHotReloadSourceSnapshotter.CaptureAfterDomainReload()synchronously on the main thread. In my project it takes about 1.9–2.3 s, which is added to every script compile even when hot reload is not used.Environment
Main) has 825 source filesHow to reproduce
ProfilerDriver.profileEditor = true; ProfilerDriver.enabled = true;).uloop compile.EditorApplication.update: HotReloadEditorStartup.<Initialize>g__CaptureOnFirstUpdateTick.Measurement
EditorApplication.update: HotReloadEditorStartup.<Initialize>g__CaptureOnFirstUpdateTickLibrary/UloopHotReload/SourceSnapshot/Main-<MVID>/with 781 files (3.3 MB).uloop compiletakes about 17.5 s (Bee build ~4.9 s, domain reload ~5.1 s), so this capture is a noticeable part of the wait.Suggestion
I understand from #3195 that the first-update hook was kept so a capture still happens early when no request comes, and that the pause point path reads the snapshot without going through the new gate. With that in mind, one of these might be worth considering: