Merge upstream main into piston branch

Co-Authored-By: Codex (GPT-6) <noreply@openai.com>
This commit is contained in:
levzzz
2026-10-27 01:15:46 +05:00
6 changed files with 197 additions and 70 deletions
+68 -6
View File
@@ -26,6 +26,11 @@ change costs only the Rust side. A harness that fails while reusing oracle
results is rerun fresh, and stops reusing them if it then passes. --all and
--fresh never reuse them.
A harness listed in parity_hosts.json's "known_flaky" (each with its reason)
that fails runs once more from scratch instead, and a pass then counts. Every
retry is printed as a RETRIED line in the summary and in the CI job's summary.
Fix the cause, then take the harness off the list: nothing else gets this retry.
Harness probes build into .local/parity-target with release optimisations but
without LTO and with 16 codegen units (`PROFILE` below), which builds in
seconds instead of minutes. Rust does not let those settings change results:
@@ -1014,11 +1019,26 @@ def harness_of(label):
return label.split("~")[0]
def run(selected, state, hasher, environment_digest, executors, reuse_oracles, rounds=None):
def keep_first_log(label):
"""Move a harness's log aside before its retry writes a new one; returns where it went."""
log = STATE_DIR / "logs" / f"{label}.log"
kept = log.with_name(f"{label}.first-run.log")
try:
log.replace(kept)
except OSError:
return log # a remote host's run: its log stays on that machine
return kept
def run(selected, state, hasher, environment_digest, executors, reuse_oracles, rounds=None, known_flaky=None):
"""Run the selected harnesses on the executors. rounds: how many times each must run (default once); its runs
must agree, and a harness that both passes and fails is reported as flaky and recorded as failing."""
must agree, and a harness that both passes and fails is reported as flaky and recorded as failing.
known_flaky ({name: reason}, tools/parity_hosts.json): a harness listed there that fails its single round runs
once more, from scratch; its record keeps `retried` (the first run's log is kept beside its own)."""
records = state["harnesses"]
rounds = rounds or {}
known_flaky = known_flaky or {}
second_chance = set() # known flaky harnesses that already failed once in this run
# Longest first, so the slow harnesses don't start last; a harness's later rounds after its first.
queue = sorted((name if index == 1 else f"{name}~{index}" for name in selected for index in range(1, rounds.get(name, 1) + 1)),
key=lambda label: (-records.get(harness_of(label), {}).get("seconds", 1e9), label))
@@ -1041,7 +1061,9 @@ def run(selected, state, hasher, environment_digest, executors, reuse_oracles, r
if pick is None:
break
name = harness_of(pick)
reuse = reuse_oracles and records.get(name, {}).get("oracle_reuse", True) and pick not in retried
# A retry runs the oracle again too: it may be the side that failed (mob_ai's heap).
reuse = reuse_oracles and records.get(name, {}).get("oracle_reuse", True) and pick not in retried \
and name not in second_chance
if not executor.start(pick, selected[name], reuse, records.get(name, {}).get("peak_bytes", DEFAULT_MEMORY),
SHARDS.get(name)):
break
@@ -1066,9 +1088,12 @@ def run(selected, state, hasher, environment_digest, executors, reuse_oracles, r
queue.insert(0, label)
continue
passed = record["status"] == "pass"
if not passed and reused and label == name and records.get(name, {}).get("status") != "fail":
flaky_retry = rounds.get(name, 1) == 1 and base_name(name) in known_flaky
if not passed and reused and label == name and records.get(name, {}).get("status") != "fail" \
and not flaky_retry:
# A new failure might come from a reused oracle result: run it again from scratch. Later rounds reuse
# what the first just validated, so their failures count (a flaky harness).
# what the first just validated, so their failures count (a flaky harness). A known flaky harness
# gets its own retry below instead, which keeps reusing oracle results afterwards.
retried.add(label)
queue.insert(0, label)
print(f"retry {label} without reused oracle results", flush=True)
@@ -1086,8 +1111,19 @@ def run(selected, state, hasher, environment_digest, executors, reuse_oracles, r
if len(done[name]) < rounds.get(name, 1):
continue
runs = done.pop(name)
if runs[0]["status"] != "pass" and flaky_retry and name not in second_chance:
second_chance.add(name)
first_log = keep_first_log(label)
print(f"RETRIED {name}: failed, and it is a known flaky harness ({known_flaky[base_name(name)]}): "
f"running it once more (first run's log: {first_log})", flush=True)
queue.insert(0, label)
continue
record = dict(runs[0], status="pass" if all(run["status"] == "pass" for run in runs) else "fail",
rounds=len(runs))
if name in second_chance:
record["retried"] = "known flaky"
elif label in retried:
record["retried"] = "reused oracle results"
if len({run["status"] for run in runs}) > 1:
record["flaky"] = [run["status"] for run in runs]
print(f"FLAKY {name}: {', '.join(record['flaky'])} in {len(runs)} runs", flush=True)
@@ -1309,12 +1345,36 @@ def platform_skips(config):
return dict(config.get("linux_only", {}))
def known_flaky(config):
"""Harnesses tools/parity_hosts.json lists as failing now and then for a cause not fixed yet: one that fails runs
once more, and passing then counts, reported as RETRIED. {name: reason}"""
return dict(config.get("known_flaky", {}))
def named_only(config):
"""Harnesses tools/parity_hosts.json keeps out of every automatic selection (--changed, --failed, the default,
--flake-check): they run only when named or with --all, the nightly audit. {name: reason}"""
return dict(config.get("named_only", {}))
def report_retries(results, flaky):
"""Say loudly which harnesses needed their one retry (a known flaky one, or one that failed with reused oracle
results), here and in the CI job's summary: a pass on the retry counts, so this is where flakes stay visible."""
def why(name, record):
if record["retried"] == "known flaky":
return (f"known flaky: {flaky.get(base_name(name), '?')}; first run's log: "
f"{STATE_DIR / 'logs' / (name + '.first-run.log')}")
return "its first run reused oracle results; it no longer reuses them" if record["status"] == "pass" else \
"its first run reused oracle results"
lines = [f"RETRIED {name}: failed, then {'passed' if record['status'] == 'pass' else 'failed again'} on its one "
f"retry ({why(name, record)})" for name, record in sorted(results.items()) if record.get("retried")]
for line in lines:
print(line, flush=True)
if lines and os.environ.get("GITHUB_STEP_SUMMARY"):
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as summary:
summary.write("### Harnesses that failed once, then ran again\n" + "".join(f"- {line}\n" for line in lines))
def finished_run(failed):
"""Record that this run completed, for tools/gate.py: a crashed runner never writes it."""
STATE_DIR.mkdir(parents=True, exist_ok=True)
@@ -1463,7 +1523,8 @@ def main():
reuse_oracles = not (args.fresh or args.all)
executors = [*remotes, LocalExecutor(jobs, int(memory_available() * 0.75), args.timeout,
REMOTE_LOCAL_PEAK if remotes and args.jobs is None else None)]
results, elapsed = run(selected, state, hasher, environment_key(hasher), executors, reuse_oracles, rounds)
results, elapsed = run(selected, state, hasher, environment_key(hasher), executors, reuse_oracles, rounds,
known_flaky(config))
finally:
for executor in remotes:
executor.stop()
@@ -1471,6 +1532,7 @@ def main():
failed = sorted(name for name, record in results.items() if record["status"] != "pass")
finished_run(failed)
print(f"\n{len(results) - len(failed)} passed, {len(failed)} failed in {elapsed / 60:.1f} min.")
report_retries(results, known_flaky(config))
for index, name in enumerate(failed):
log = STATE_DIR / 'logs' / (name + '.log')
print(f" {name}: {log}")
+5
View File
@@ -42,5 +42,10 @@
"linux_only": {},
"named_only": {
"lan_integration": "the whole lan_e2e suite: ~40 min a run on a loaded runner, and single checks flake under load; run it by name, or tools/lan_e2e.py"
},
"known_flaky": {
"dedicated_server": "its Java client moves to the next step on a 1.5 s timer, not on the server's reply: under load a respawn's add_entity/update_attributes or entity_event 19 lands in the wrong step (failed, then passed at the same head, 10-26)",
"remote_fireball": "samples the fireball on the wall clock, so a slow host sees it in too few samples (desktop runner, 3 times on 10-26)",
"world_reopen": "counted 4 minecarts instead of 3 once on a loaded Mac mini runner, then passed at the same head (10-26)"
}
}