Commit Graph
4 Commits
Author SHA1 Message Date
sneeker 4eac7cd845 fix(sched): kill running actions when meowc is interrupted
Ctrl-C killed meowc and left every compiler it had spawned running, still
holding CPU and still about to write into the build directory. There were no
signal handlers at all.

SIGINT and SIGTERM now cancel the same way a build failure does, and the run
returns cleanly so the cache is still written and the exit status is 130. A
second signal falls through to the default handler, so an unresponsive child
cannot trap the user.

Signalling a single pid was not enough: a compiler driver spawns its own
children, and those were reparented to init and survived. Each action is now
placed in its own process group with setsid, and cancellation signals the group,
which also makes the existing failure path reach grandchildren. Unix.wait is
retried on EINTR so a signal arriving mid-wait is not fatal.
2022-07-15 14:41:20 +00:00
sneeker 752ddea916 feat(sched): cancel in-flight actions when a build fails
Only new spawns were held back after a failure, so every action already running
was allowed to finish even though its output would be discarded. The scheduler
now sends SIGTERM to the remaining children on the first failure, and reports
them separately rather than counting a process it killed as a failure of its
own. Partial outputs are removed and their cache entries dropped, so the next
run starts clean.

Under -k the existing behaviour is kept, since keeping going is the point.

On a graph with three six-second generators alongside one translation unit that
fails immediately, -j4 now returns in 0.12 s rather than 6.03 s.
2022-07-15 04:18:43 +00:00
sneeker 2ce144e8aa perf(cache): memoise file digests and invalidate them on write
A header included by fourteen translation units was hashed once per dependent,
and every built action hashed its inputs twice: once to decide it was stale and
again to store the new key. Digests are now memoised for the run, and the
scheduler drops the entries for an action's outputs and depfile once it
finishes, so a freshly written file is never read from the memo.
2022-07-12 08:44:33 +00:00
sneeker 720efd5c74 feat(sched): dispatch ready actions under a job limit
Checks each node's key at the moment it becomes ready rather than up front,
because an input may have been produced by a node that ran seconds earlier.
This is what gives early cutoff.
2022-06-15 20:17:47 +00:00