cortesi/modd

Don't rerun unnecessarily

relnod opened this issue · 3 comments

Hi,
I have the problem, that it takes quite a while to run my prep commands. If I change a file three times and save it each time, the prep commands always get triggered, even if all file changes were already run on the second time.
Is it possible to add a check to see if a new run is unnecessary? So that when the prep command is running and I save two files during that time, the prep command only gets triggered once afterwards.

This is tricky. We have a heuristic that batches up file changes until we see a lull, or reach a timeout. After that, changes are actioned. This is only a heuristic, and I don't think there's any way to tune this to satisfy all users in all circumstances.

To give me a bit more information to go on, could you please tell me:

  • Approximately how long your prep job takes to run
  • Approximately what interval are you making the changes at (e.g. one a second)
  • Which platform you're on

Also any further detail you think might apply.

Closing, more info needed. Please re-open with some more info if you'd like me to pursue this.

@cortesi
I agree with @relnod.
Easy repro steps:

  1. Clone https://github.com/golang-templates/seed
  2. Run modd
  3. Open foo.go or foo_test.go
  4. Make some file changes e.g. add space and save the file
  5. Execute the previous step very fast a lot of times e.g. 30 times
  6. Notice that modd executes the build 30 times

I think you can add a state machine to modd. E.g.

  1. State "idle - waiting for file changes" - it watches for file changes. If a file is changed then you go to next state.
  2. State "executing prep - waiting for file changes" - start executing the prep. When the prep has finished then go to state 1. If a file changed during prep execution go to next state.
  3. State "executing prep - next prep execution queued". When the prep finishes then just go to previous step (rerun the prep and wait for new file changes).

Disclaimer, I had not time to look at modd source code.

Tested on v0.8