-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Configurable file watcher debounce duration in live-reload mode #2938
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
base: next
Are you sure you want to change the base?
Conversation
Let the file watcher use a configurable debounce value. This commit preserves the (until now hard-coded) 1-second debounce value as the default, but adds a new flag for the `serve` command, which lets the user configure a debounce duration for consecutive rebuilds in watch mode. Closes getzola#2937. Ref: getzola#2937 Ref: https://zola.discourse.group/t/watch-debounce-configuration/2666
Something's not quite right: you shoudn't use |
My advice would be to error, or at least warn, in the case of |
I like that as well, I'll get right on it. |
Also, it would be good to document the flag ( |
a8e9f14
to
676c846
Compare
Done, and done. I looked into the reason for the excessive CPU load with The "ideal" resolution may have been to somehow bypass using the debouncer altogether if the user passes My puny mammalian brain can't really feel the difference between 1ms and 0ms anyways ;) |
The `tick_rate` at which the debouncer library checks whether any events should now be dispatched shouldn't be 0. It cannot either be any greater than the debounce rate itself. Ideally, we may want to *disable* debouncing altogether when the user passes --debounce 0, but that'd require a special case to be made in the instrumentation, where we'd bypass the debouncer: that's another package to depend on, and ultimately deemed no worth the hassle. Ref: getzola#2937 Ref: https://zola.discourse.group/t/watch-debounce-configuration/2666
676c846
to
b1842cf
Compare
The code looks fine, i'm just a bit hesitant about adding more flags to the CLI |
In practice though, is it actually worth it to have a debounce value that small? Zola is going to rebuild the thing every few (or even just every) keystrokes which seems a bit wasteful |
Hang on a second: does Zola watch as you type, not as the files are changed on disk? Surely that can't be, without some curious integration with your text editor. Or are you actually reflecting the changes back to your filesystem as you type? TL;DR: What I'm observing is:
With |
The line was too long. I pruned the /*tick_rate=*/ inline comment that was indicating the name of the argument it was annotating, since it was *the exception*: there are zero other occurrences of such notation throughout this codebase.
No but with auto-saving editors it might happen frequently enough |
Oh alright. I would presume then that the debouncing happens at that level, where the editor wouldn't save your file to disk after each keystroke. For myself, waiting one full second after I've virtually instructed Zola to rebuild my site is a bit of an irritation. |
I just had a thought: what if we lower the debounce from 1000 ms to a lower value, say 50 or 100 ms, and ditch the complexity of an extra CLI flag? |
I've just tried in rustrover with a 50ms debounce and I do often get multiple builds in the same second (mostly when using backspace) so that would be a lot of wasted cpu for my own usecase :/ |
@Keats, I think we'd all—but you primarily—benefit from understanding what is going on. It's quite possible that you've configured something to commit changes, as you type, back to your filesystem (exceedinly?) often, apparently with some throttle or debounce: naively, I'd say that's an undesirable configuration. Regardless, I truly don't think that your specific, undiagnosed set-up being quite curious should be the sole blocker that prevents a 3ms rebuild to take anything less than 1003ms. -- Here's the isolated, minimal, complete, verifiable example I could prepare. You only need Docker:
docker run --rm -it --network=host --name=zola archlinux sh
pacman -Sy --noconfirm git vim rust cargo
git clone --depth 1 --branch configurable-watcher-debounce https://github.com/ccjmne/zola
cd zola; cargo build --release
cd test_site; ../target/release/zola serve -fd1 On your local machine, navigate to
docker exec -it zola vim /zola/test_site/templates/index.html -- Zola truly is a pretty neat tool, thank you for that! Now if you still think that, in principle, waiting around is what is ultimately desirable for the project, that's acceptable. If you truly suspect that any (let alone a very large) debouncing is required, I'm not entirely convinced, and can't quite arrive to the same conclusion through my (admittedly modest) test. |
My previous message sounded harsh. If you really do want to figure out what I presume is writing to your disk surprisingly (unnecessarily?) often, I'd be genuinely curious and willing to help and find out. If you want another parir of investigative eyes, I'd be happy to try and help! |
-d
--debounce <VALUE>
flag forserve
serve
's--debounce
flag incli-usage.md
Let the file watcher use a configurable debounce value.
This commit preserves the (until now hard-coded) 1-second debounce value
as the default, but adds a new flag for the
serve
command, which letsthe user configure a debounce duration for consecutive rebuilds in watch
mode.
Closes #2937.