The golden-test verify subcommand is becoming weirdly slow (1.9 seconds when run on the abc repo). Profiling shows that the cause of slowness is mostly dealing with temp files, especially in our diff implementation which creates a copy of the files being diffed.
This PR just adds some coarse-grained concurrency at the top level of the verify command. There's still room for improvement, but this is a decent start.
Ways to improve performance further in the future:
Fix our diff algorithm. To smooth over the differences between Linux diff and MacOS/BSD diff, we have a gross hack where we invoke git diff. To do that we have to copy the two files being diffed into a temp directory before running git diff. This wastes a LOT of time. There seems to be no good unified diff library for Go, which is unfortunate.
More concurrency:
Concurrently render the test cases, not just the the diffing
Concurrently run diffs for the test cases within a single test. Currently all the test cases for a single template run in teh same worker thread.
parallelize temp dir cleanup inside tempdir.DirTracker. This might suck if we have to reimplement os.RemoveAll() 😟 .
The
golden-test verify
subcommand is becoming weirdly slow (1.9 seconds when run on the abc repo). Profiling shows that the cause of slowness is mostly dealing with temp files, especially in ourdiff
implementation which creates a copy of the files being diffed.This PR just adds some coarse-grained concurrency at the top level of the verify command. There's still room for improvement, but this is a decent start.
Ways to improve performance further in the future:
git diff
. To do that we have to copy the two files being diffed into a temp directory before running git diff. This wastes a LOT of time. There seems to be no good unified diff library for Go, which is unfortunate.