Repository navigation
ci: share local check capacity across worktrees #6256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d6be52d
chore(quest): claim quest/m0/ci/local-gate.md
kixelated ee0fe08
ci: share local check capacity across worktrees
kixelated 8711acd
Merge remote-tracking branch 'origin/main' into quest/m0/ci/local-gate
kixelated 765230e
quest: retire local check admission
kixelated c51900d
fix(sh): adopt orphans so cancellation reaches the whole tree
kixelated 99d893b
Merge remote-tracking branch 'origin/main' into quest/m0/ci/local-gate
kixelated 0055d9f
Merge remote-tracking branch 'origin/main' into fix-6256
kixelated eabf885
Merge remote-tracking branch 'origin/main' into merge-6256
kixelated f6930b7
fix(bench): run every checkout solo and alternate run order
kixelated cd49537
Merge remote-tracking branch 'origin/main' into merge-6256
kixelated e46cb21
Merge remote-tracking branch 'origin/main' into HEAD
kixelated 4cb4700
docs(bench): drop a doubled blank line left by the main merge
kixelated fc8d17b
Merge remote-tracking branch 'origin/main' into HEAD
kixelated d5e9e8e
Merge remote-tracking branch 'origin/main' into HEAD
kixelated 53cb206
bench: sweep check lanes in bench-local
kixelated fca1ec1
test: keep tooling tests out of the host gate
kixelated 53fef2c
docs: name the check lanes beside admission
kixelated a5bfae7
Merge remote-tracking branch 'origin/main' into HEAD
kixelated 217d8d7
bench: record the lane count bench-local actually ran
kixelated b4c4746
Merge remote-tracking branch 'origin/main' into HEAD
kixelated 66dd38d
ci: re-exec select.sh by root-relative paths
kixelated 7588b93
Merge remote-tracking branch 'origin/main' into local-gate-merge
kixelated 7afe014
Merge remote-tracking branch 'origin/main' into quest/m0/ci/local-gate
kixelated File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,94 @@ | ||
| #!/usr/bin/env python3 | ||
| """Compare suite fanout across isolated checkouts, separating admission from work.""" | ||
|
|
||
| import argparse | ||
| import json | ||
| import os | ||
| from pathlib import Path | ||
| import subprocess | ||
| import signal | ||
| import sys | ||
| import time | ||
| import uuid | ||
|
|
||
|
|
||
| ROOT = Path(__file__).resolve().parents[1] | ||
|
|
||
|
|
||
| def main(): | ||
| if sys.argv[1:2] == ["--started"]: | ||
| started = time.monotonic() | ||
| result = subprocess.run(sys.argv[3:]) | ||
| Path(sys.argv[2]).write_text(json.dumps({"start": started, "end": time.monotonic()})) | ||
| sys.exit(result.returncode) | ||
| parser = argparse.ArgumentParser(description=__doc__) | ||
| parser.add_argument("--checkout", action="append", type=Path, required=True) | ||
| parser.add_argument("--workers", nargs="+", type=int, required=True) | ||
| parser.add_argument("--jobs", nargs="+", type=int, help="MOQ_CHECK_JOBS lane counts to sweep") | ||
| parser.add_argument("--samples", type=int, default=3) | ||
| parser.add_argument("--cache", required=True, help="Describe the prepared cache state") | ||
| parser.add_argument("command", nargs=argparse.REMAINDER) | ||
| args = parser.parse_args() | ||
| command = args.command[1:] if args.command[:1] == ["--"] else args.command | ||
| if not command or args.samples < 1 or any(n < 1 for n in args.workers + (args.jobs or [])): | ||
| parser.error("a command, positive samples and positive worker and job counts are required") | ||
| if os.name != "posix": | ||
| parser.error("CPU accounting requires a POSIX host") | ||
| checkouts = [checkout.resolve() for checkout in args.checkout] | ||
| if not all(checkout.is_dir() for checkout in checkouts) or len(set(checkouts)) != len(checkouts): | ||
| parser.error("each checkout must be a distinct existing directory") | ||
| # Every checkout runs solo, so a concurrent run is compared against its own baseline. | ||
| groups = [[checkout] for checkout in checkouts] + ([checkouts] if len(checkouts) > 1 else []) | ||
| def cancel(number, _frame): | ||
| raise SystemExit(128 + number) | ||
| for number in (signal.SIGTERM, signal.SIGHUP): | ||
| signal.signal(number, cancel) | ||
| # Alternating the order spreads drift in host load or thermals over solo and concurrent runs. | ||
| for sample in range(args.samples): | ||
| for group in groups if sample % 2 == 0 else reversed(groups): | ||
| for workers, jobs in ((w, j) for w in args.workers for j in args.jobs or [None]): | ||
| processes = [] | ||
| load = os.getloadavg() | ||
| try: | ||
| for checkout in group: | ||
| directory = checkout / ".scratch/local-bench" | ||
| directory.mkdir(parents=True, exist_ok=True) | ||
| stem = directory / str(uuid.uuid4()) | ||
| stamp = stem.with_suffix(".started") | ||
| with stem.with_suffix(".log").open("w") as log: | ||
| env = dict(os.environ, NEXTEST_TEST_THREADS=str(workers)) | ||
| # Without --jobs, the record's null means sh/dispatch.sh's default. | ||
| env.pop("MOQ_CHECK_JOBS", None) | ||
| if jobs: | ||
| env["MOQ_CHECK_JOBS"] = str(jobs) | ||
|
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| env.pop("QUEST_GATE_ADMITTED", None) | ||
| env.pop("MOQ_LOCAL_SUPERVISED", None) | ||
| env.pop("GITHUB_ACTIONS", None) | ||
| began = time.monotonic() | ||
| process = subprocess.Popen(["bash", str(ROOT / "sh/local.sh"), sys.executable, | ||
| str(Path(__file__).resolve()), "--started", str(stamp), | ||
| *command], cwd=checkout, env=env, stdout=log, stderr=log) | ||
| processes.append((process, began, stamp)) | ||
| results = [] | ||
| for process, began, stamp in processes: | ||
| _, status, usage = os.wait4(process.pid, 0) | ||
| process.returncode = os.waitstatus_to_exitcode(status) | ||
| if process.returncode: | ||
| raise RuntimeError(f"command failed ({process.returncode}); see {stamp.with_suffix('.log')}") | ||
| timing = json.loads(stamp.read_text()) | ||
| started, ended = timing["start"], timing["end"] | ||
| results.append({"admission_s": started - began, "work_s": ended - started, | ||
| "total_s": ended - began, "cpu_s": usage.ru_utime + usage.ru_stime}) | ||
| finally: | ||
| for process, _, _ in processes: | ||
| if process.returncode is None: | ||
| process.terminate() | ||
| process.wait() | ||
| print(json.dumps({"copies": len(group), "checkouts": [str(checkout) for checkout in group], | ||
| "nextest_workers": workers, "check_jobs": jobs, "sample": sample, | ||
| "cache": args.cache, "host_load": load, "command": command, | ||
| "runs": results}), flush=True) | ||
|
|
||
|
|
||
| if __name__ == "__main__": | ||
| main() | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.