jacereda / fsatrace

Filesystem access tracer
ISC License
81 stars 12 forks source link

Observe files queried #8

Closed ndmitchell closed 8 years ago

ndmitchell commented 8 years ago

Not sure if this is possible, but it would be good if fsatrace could write some information whenever a file had its modification time queried, something like q|filename. If this worked, then it would be very easy to speed up slow rebuild checkers, using Shake. For example, on my system cabal build takes 0.625s, but in certain circumstances, ghc --make can take > 1 min. If you could run fsatrace - -- cabal build, and then capture everything it reads and queries, and only rerun if any of that changes, you could reduce the rebuild time to 0.01s. The tool ghc-make already does that using custom logic for ghc --make, but with fsatrace it could be totally generic and I could kill ghc-make entirely.

jacereda commented 8 years ago

This one is trickier, but https://github.com/jacereda/fsatrace/compare/stat seems to work properly on Darwin.

jacereda commented 8 years ago

Linux version is even more ugly. I'll attempt Windows tomorrow.

jacereda commented 8 years ago

I guess we need a flag to tell what ops you're interested in to reduce parsing cost.

ndmitchell commented 8 years ago

Agreed, flags would be very useful.

jacereda commented 8 years ago

I'm interested in such a tool, in my case stack build takes 2.2 secs.

ndmitchell commented 8 years ago

Writing it on top of the shake forward mode I added is trivial. I was going to have shake --forward -- stack build do it.

jacereda commented 8 years ago

Can you try this one? https://github.com/jacereda/fsatrace/compare/file-args

For some reason the travis build gets stuck on Mac, I can't reproduce it here.

ndmitchell commented 8 years ago

Some results:

C:\Neil\neil>cabal --version
cabal-install version 1.22.6.0
using version 1.22.4.0 of the Cabal library

C:\Neil\neil>fsatrace rwqmv - -- cabal --version
fsatrace.exe(8092): error: verbose
argv[0]=cabal
argv[1]=--version
cabal --version
cabal-install version 1.22.0.0
using version 1.22.0.0 of the Cabal library

C:\Neil\neil>fsatrace rwqmvv - -- cabal configure
fsatrace.exe(7668): error: verbose
argv[0]=cabal
argv[1]=configure
cabal configure
Fatal: win/utf8.c:9: l || !sl, err: 7a
fsatrace.exe(7668): error: command failed with code 777
argv[0]=cabal
argv[1]=configure

C:\Neil\neil>fsatrace rwqmv - -- cmd /c cabal build
fsatrace.exe(1704): error: verbose
argv[0]=cmd
argv[1]=/c
argv[2]=cabal
argv[3]=build
cmd /c cabal build
Building neil-0.10...
Preprocessing executable 'neil' for neil-0.10...
r|C:\Windows\Globalization\Sorting\SortDefault.nls

So:

The neil directory is a checked out copy of https://github.com/ndmitchell/neil, but I have no reason to think that is particularly relevant.

jacereda commented 8 years ago

What does this yield?

where cabal
fsatrace q - -- where cabal

As for invoking cabal via cmd, you probably want

fsatrace q - -- cmd /c "cabal build"

(Note the quotes)

I think I fixed the utf8 error.

ndmitchell commented 8 years ago
C:\Neil>where cabal
C:\ghc\minghc-7.10.2-i386\bin\cabal.exe
C:\bin\cabal.exe
C:\Program Files (x86)\MinGHC-7.8.3\bin\cabal.exe

C:\Neil>fsatrace q - -- where cabal
where cabal
C:\ghc\minghc-7.10.2-i386\bin\cabal.exe
C:\bin\cabal.exe
C:\Program Files (x86)\MinGHC-7.8.3\bin\cabal.exe

I'll do some more digging tonight.

jacereda commented 8 years ago

Is this one fixed?

ndmitchell commented 8 years ago

Seemingly - both now give the same cabal version. Whether that is due to changes in fsatrace or the things on my PATH I don't really know... Sorry I totally forgot about this bug.

jacereda commented 8 years ago

Good, closing.