Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

build runner: make watched Compile steps keep the compiler alive #20600

Closed
andrewrk opened this issue Jul 13, 2024 · 0 comments · Fixed by #20633
Closed

build runner: make watched Compile steps keep the compiler alive #20600

andrewrk opened this issue Jul 13, 2024 · 0 comments · Fixed by #20633
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

Comments

@andrewrk
Copy link
Member

andrewrk commented Jul 13, 2024

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.

@andrewrk andrewrk added 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 labels Jul 13, 2024
@andrewrk andrewrk added this to the 0.14.0 milestone Jul 13, 2024
andrewrk added a commit that referenced this issue Jul 15, 2024
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.

Closes #20600
eric-saintetienne pushed a commit to eric-saintetienne/zig that referenced this issue Jul 16, 2024
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.

Also adds global zig cache to the compiler cache prefixes.

Closes ziglang#20600
SammyJames pushed a commit to SammyJames/zig that referenced this issue Aug 7, 2024
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.

Also adds global zig cache to the compiler cache prefixes.

Closes ziglang#20600
igor84 pushed a commit to igor84/zig that referenced this issue Aug 11, 2024
Changes the `make` function signature to take an options struct, which
additionally includes `watch: bool`. I intentionally am not exposing
this information to configure phase logic.

Also adds global zig cache to the compiler cache prefixes.

Closes ziglang#20600
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant