build runner: make watched Compile
steps keep the compiler alive
#20600
Labels
enhancement
Solving this issue will likely involve adding new logic or components to the codebase.
zig build system
std.Build, the build runner, `zig build` subcommand, package management
Milestone
Extracted from #20580.
Currently, when using
zig build --watch
, any Compile steps will re-execute the zig compiler process each time the step is invalidated.The next step here is to make the build runner keep the compiler subprocess alive, sending it update() requests when file system notifications come in.
There are three reasons for this:
Regarding performance, it helps in two ways. First, it avoids many calls to fstat. Even a cache hit on on a large project can be delayed by the time it takes to check that all the file system inputs are up-to-date. More importantly, it means that incremental compilation can be performed without compiler state serialization. It means we can land incremental compilation before implementing state saving and loading, troubleshoot serialization issues by comparing with
--watch
behavior, and avoid doing serialization/deserialization work.As for a compiler server, the build runner will have a meta-protocol that multiplexes between multiple compiler servers. Obviously the compiler needs to be alive and running in order to report type information and do other things like this!
Finally, for hot code swapping, again the compiler needs to be alive and running in order to track the application's virtual memory and issue the debugger API calls to perform the code swap.
The text was updated successfully, but these errors were encountered: