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

Add way to build project with -fno-emit-bin flag set for error reporting #870

Closed
Jarred-Sumner opened this issue Dec 31, 2022 · 7 comments
Closed
Assignees
Labels
enhancement New feature or request priority:medium Medium priority item ux User experience improvement

Comments

@Jarred-Sumner
Copy link
Contributor

This would fix #869 and #868 in a maintainable way and bring the Zig developer experience closer to what mature programming languages like Rust or Go have.

@Jarred-Sumner Jarred-Sumner added the enhancement New feature or request label Dec 31, 2022
@SuperAuguste
Copy link
Member

@sin-ack was talking about this in the Zig Discord and I think it's a great idea, there are just a few performance things we need to consider. This is probably something that should be implemented with threads + request cancellation/continuation.

@Jarred-Sumner
Copy link
Contributor Author

-fno-emit-bin should be fast enough for most projects. For bun, it's 8 seconds on an M1 (16 seconds on linux). That is too long, but Bun is one of the largest Zig projects so it should be a lot faster for everyone else.

If you use an event loop + posix_spawn and then disable the filesystem locking for zig cache (which prevents multiple instances to run), it should work well enough. posix_spawn is faster when the process uses lots of memory. The event loop should monitor file descriptor readiness so you can call waitpid without blocking the thread. This design would let you keep zls as one thread and start multiple instances of zig build without waiting for previous ones to complete. If there is no easy way to prevent file locking, maybe just have a pool of up to 8 or so instances of zig build each with 8 different caches and cycle through each one

@SuperAuguste
Copy link
Member

With that benchmark in mind this actually makes sense to do, I'll try my hand at hacking away at it :)

@SuperAuguste SuperAuguste self-assigned this Dec 31, 2022
@SuperAuguste SuperAuguste added priority:medium Medium priority item ux User experience improvement labels Dec 31, 2022
@SuperAuguste
Copy link
Member

I think I'll just get something simple and platform independent working first and then I might look at optimizing it if it's really outrageously slow or something :P

@SuperAuguste
Copy link
Member

image

Tada! Very rudimentary and it's pretty slow but at least it works :)

@SuperAuguste
Copy link
Member

So I implemented this in its hacky asynchronous entirety (on Windows at least) and sadly some concerns I had turned out to be true: it is straight up unusable. I'm testing this on a fresh zig init-exe and it takes a good 5 seconds between saves which is already pretty bad (this is with all emits off btw). The experience is then worsened by the fact that whenever I try and fix an error by modifying my code, all the indices are all completely off.

oof.mp4

Sadly, I think this makes this feature wholly useless for most people :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority:medium Medium priority item ux User experience improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants