go-task / task

A task runner / simpler Make alternative written in Go
https://taskfile.dev
MIT License
11.36k stars 613 forks source link

Make watch interval configurable (currently fixed at 5 seconds) #813

Closed gregorriegler closed 2 years ago

gregorriegler commented 2 years ago

I have gradle -t test (this is watching for file-changes and then reruns the tests) and task test --watch open at the same time and task is significantly slower. It reacts to filechanges about a second later, while gradles watcher is instant. Do you see an easy way to make it faster?

ghostsquad commented 2 years ago

Can I ask you to provide a minimal reproduction for Gradle and Task so that benchmarks can be made and used for comparison?

gregorriegler commented 2 years ago

watch-slow.zip So i made this zip. In the left corner we have Taskfile

version: '3'

tasks:
  test:
    cmds:
      - echo Taskfile
    sources:
      - test.txt

fighting against the oldschooler in the right corner: Makefile with inotifywait

.PHONY: test
test: 
    echo "Makefile";

.PHONY: watch
watch: 
    while true; do \
        make test; \
        inotifywait -qr -e modify -e create -e delete -e move test.txt; \
    done

run both, and change test.txt to trigger the task.

renatoathaydes commented 2 years ago

Looks like the watch command polls every 5 seconds? https://github.com/go-task/task/blob/master/watch.go#L19 The library being used to poll file system events does not use inotify (as that's not available on all OSs)...

andreynering commented 2 years ago

Hi everybody,

I believe that having an attribute on the Taskfile (and possible a flag, too) to have a different polling interval would do the trick here.

We could also consider switching to a library that uses the OS notification API, but I wanted to avoid it initially because it may behave differently based on the user's OS.

gregorriegler commented 2 years ago

I use watchexec and just right now. So I'm not waiting for this. But I think it could be beneficial for you to have it built in. Easier setup and scripting for users.

We could also consider switching to a library that uses the OS notification API, but I wanted to avoid it initially because it may behave differently based on the user's OS.

Do you say 'may' because we're not sure? In that case I recommend trying For the thing I'm doing I'm not sure if an interval would be sufficient. But maybe it's worth trying, too

ilewin commented 2 years ago

I'd like to give it a try.

andreynering commented 2 years ago

This was implemented by @ilewin at #865.

I plan to make a new release still today.