|
|
|
|
|
by jiggawatts
630 days ago
|
|
From the Build Systems à la Carte paper: Topological. The topological scheduler pre-computes a linear order of tasks, which when
followed, ensures the build result is correct regardless of the initial store. Given a task description
and the output key, you can compute the linear order by first finding the (acyclic) graph of the
key’s reachable dependencies, and then computing a topological sort. However this rules out dynamic dependencies. Restarting. To handle dynamic dependencies we can use the following approach: build
tasks in an arbitrary initial order, discovering their dependencies on the fly; whenever a task
calls fetch on an out-of-date key dep, abort the task, and switch to building the dependency dep;
eventually the previously aborted task is restarted and makes further progress thanks to dep now
being up to date. This approach requires a way to abort tasks that have failed due to out-of-date
dependencies. It is also not minimal in the sense that a task may start, do some meaningful work,
and then abort. Suspending. An alternative approach, utilised by the busy build system and Shake,
is to simply build dependencies when they are requested, suspending the currently running task.
By combining that with tracking the keys that have already been built, one can obtain a minimal
build system with dynamic dependencies. This approach requires that a task may be started and then suspended until another task is complete. Suspending can be done with cheap green threads and blocking (the original approach
of Shake) or using continuation-passing style (what Shake currently does). |
|