I have the following build system
module Main where
import Development.Shake
main :: IO ()
main = shakeArgs shakeOptions $ do
"a" %> \out -> do
need ["a.in"]
cmd_ "sleep" "10"
cmd "touch" [out]
which I build with stack build
and run with stack exec myShake -- --progress a
.
If I do a clean build and than touch a.in
and run again, shake shows me very wrong progress predictions. Sometimes it predicts 1000 minutes and more.
(As I get a progress prediction in the title bar of my terminal every 5 seconds, if I understood this correctly, I only talk about the first progress prediction here, as this is the only one I get with this build system example.)
I use lts-9.6 with stack and shake version 0.16 (via git + an entry in packages in stack.yaml).
The documentation for how progress works can be found at progressDisplay
:
The current implementation is to predict the time remaining (based on
timeTodo
) and the work already done (timeBuilt
). The percentage is then calculated asremaining / (done + remaining)
, while time left is calculated by scaling remaining by the observed work rate in this build, roughlydone / time_elapsed
.
In the case of very short build systems which only do a single thing the work-rate is generally garbage - so you end up scaling the work remaining (which is probably predicted at 10s) with a random number (presumably a big number, to get 1000m).
The idea of work rate changing is that sometimes you are on a laptop on battery power vs mains power, and sometimes you pass different parallelism flags. It's quite possible Shake should use either one or number of threads as an approximation of the work rate, at least to begin with.