Description
The code to create a span says that it is not in general possible to know when compilation has completed. This is true. While we can/should extend the plugin API to have a hook for "on compilation completion," it may also be possible to record an approximation of this.
Right now, we're using hotel-california
to record the entire time spent in the make build
process. But this includes the time spent in cabal
and the time spent reading interface files etc in GHC before we even start compiling. So there's some ambiguity anyway with that span.
Options (all bad/need further investigation)
addFinalizer
One (bad) option is to use addFinalizer
. This has a big caveat - the Implementation Notes
section calls out that the GC may not be run on program exit, and that's exactly what we're trying to determine. If we had a way to install a hook to do a GC before exit, then we'd also have the ability to just close the span directly.
Root Modules
One option is to use the "root modules" as an approximation. This is the code for that. There's an existing caveat that we don't know which root module is the last to be compiled. If we could figure that out, then we'd have a decent way of determining a way to do that.
I don't think we can rely on root modules being compiled close to each other in time. Imagine a package with root modules A
and B
. A
depends on modules in A.{A0 - A10}
, and should finish compiling relatively quickly. But B
depends on B.{B0 - B1000}
, and will take much longer. Both A
and B
are root modules, but A
should complete faster, and so we can't just have a "tickler" that starts a timer every time a root module is compiled (and then closes the span whenever the time limit is reached for other root modules to complete).
The ModuleGraph
type contains a list of ModuleGraphNode
. Perhaps we could dig in here to determine root with the largest dependency graph?
Activity