localexec: reap the spawn helper so local CPU time is accounted Since the out-of-process spawn helper landed, non-console actions run as children of the helper instead of siso. The helper reaps each action, so all of their CPU time accumulates in the helper's rusage cutime. Nothing ever waited on the helper, so on siso exit it was orphaned to init and its cutime was discarded. getrusage(RUSAGE_CHILDREN) up the tree therefore never saw the local build's CPU: A local offline build of base shows 49% CPU (16.7 core-s) before and 2998% CPU (991 core-s) after, with identical wall time and step count. To fix this, close the control socket on Siso shutdown so the helper drains and exits, then wait for it to roll the helper's accumulated child rusage up into siso. Tested: - No-op on non-unix, where there is no helper. - Wall time is unchanged, so the extra wait adds no latency. - Single Ctrl-C interrupt cancels the build context and the function returns normally, so StopHelper runs and the cancelled build's CPU is still accounted (verified: a build stopped after 4s reports 97s user CPU). A second Ctrl-C still hard-exits via os.Exit without waiting, on purpose; the helper drains its own children on socket EOF, so nothing is orphaned. - Added a regression test that runs a CPU-burning action through the helper and asserts its CPU shows up in the process's RUSAGE_CHILDREN after StopHelper. Without the wait the delta is zero. Bug: 531402317 Change-Id: I65bdcdacfb07bfb17da9e1304f10c1d48f05a483 Reviewed-on: https://chromium-review.googlesource.com/c/build/+/8045440 Auto-Submit: Philipp Wollermann <philwo@google.com> Reviewed-by: Fumitoshi Ukai <ukai@google.com> Commit-Queue: Philipp Wollermann <philwo@google.com>
This repository contains tools developed and owned by the Chrome Build Team.
The steps for getting the code are:
git clone https://chromium.googlesource.com/buildWe use the standard Go module workflow to work on our projects.