Repository navigation
fix(klaud): requeue only PRs main superseded and count live candidates toward the backlog cap / fix(klaud):仅重新排队被 main 取代的 PR,并将进行中候选计入积压上限 #5051
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -19,9 +19,10 @@ | |
| from pathlib import Path | ||
|
|
||
| from . import github | ||
| from .github import VerificationError | ||
| from .lifecycle import BOT, CANDIDATE_ID, COMMITTER, owned_activity | ||
| from .models import REQUEUE_LABEL, Ownership, utc | ||
| from .reporting import translated | ||
| from .models import REQUEUE_LABEL, Ownership, family_keys, normalized_image, utc | ||
| from .reporting import baseline_from_body, translated | ||
|
|
||
| CHANGELOG = "inferencex-e2e/perf-changelog.yaml" | ||
| COMMITTER_EMAIL = "41898282+github-actions[bot]@users.noreply.github.com" | ||
|
|
@@ -230,29 +231,57 @@ def owned_candidates(repository: str, claimed: list[Ownership]) -> set[str]: | |
| return owned | ||
|
|
||
|
|
||
| def superseded(body: str, images: dict[str, str]) -> tuple[str, str] | None: | ||
| """Return why main superseded the finished PR with ``body`` in English and Chinese, or None. | ||
|
|
||
| ``images`` maps each single-key family on main to its normalized image. The PR is | ||
| superseded once main removed a key of its frozen baseline's family or put one on another | ||
| image than the baseline froze. A body without a readable baseline is never superseded. | ||
| """ | ||
| try: | ||
| baseline = baseline_from_body(body) | ||
| except VerificationError: | ||
| return None | ||
| if baseline is None: | ||
|
Comment on lines
+241
to
+245
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🟡 (optional) A stale finished PR whose body baseline is missing or no longer parses is now never requeued, so it keeps its family and backlog place until someone closes it by hand. Why this was flaggedThe condition is a finished Klaud PR older than STALE_DAYS (5) whose body holds no Verification: |
||
| return None | ||
| source = baseline.family.split(":", 1)[0] | ||
| for key in family_keys(baseline.family): | ||
| current = images.get(f"{source}:{key}") | ||
| if current is None: | ||
| return ( | ||
| f"main removed config key `{key}` of this family", | ||
| f"main 已移除该配置族的配置键 `{key}`", | ||
| ) | ||
| frozen = baseline.keys[key].image if baseline.keys else baseline.image | ||
| if current != normalized_image(frozen): | ||
| return ( | ||
| f"main moved config key `{key}` of this family to another image", | ||
| f"main 已将该配置族的配置键 `{key}` 更新为其他镜像", | ||
| ) | ||
| return None | ||
|
|
||
|
|
||
| def requeue_superseded( | ||
| repository: str, | ||
| pulls: list[dict], | ||
| offered: dict[str, set[str]], | ||
| images: dict[str, str], | ||
| claimed: list[Ownership], | ||
| now: datetime, | ||
| ) -> list[int]: | ||
| """Close finished PRs older than STALE_DAYS whose family the feed offers on a newer image. | ||
| """Close finished PRs older than STALE_DAYS that main ``superseded``. | ||
|
|
||
| ``offered`` maps each family branch prefix to the image keys the planner would build its | ||
| candidates from. A finished PR started from an image its family no longer offers is | ||
| superseded, but still occupies the family. Closing it with REQUEUE_LABEL returns the family | ||
| to the pool. PRs a session still owns are skipped. Writes use ``$KLAUD_REQUEUE_TOKEN`` and | ||
| return the closed PR numbers. | ||
| ``images`` maps each single-key family on main to its normalized image. A superseded PR | ||
| still occupies its family and the review backlog, and closing it with REQUEUE_LABEL returns | ||
| the family to the pool. PRs a session still owns are skipped. Writes use | ||
| ``$KLAUD_REQUEUE_TOKEN`` and return the closed PR numbers. | ||
| """ | ||
| stale = [] | ||
| for pull in pulls: | ||
| candidate = finished(repository, pull) | ||
| if not candidate or now - utc(pull["created_at"]) < timedelta(days=STALE_DAYS): | ||
| continue | ||
| prefix, image = candidate.split("-") | ||
| if offered.get(prefix) and image not in offered[prefix]: | ||
| stale.append((pull, candidate)) | ||
| if reason := superseded(pull.get("body") or "", images): | ||
| stale.append((pull, candidate, reason)) | ||
| if not stale: | ||
| return [] | ||
| try: | ||
|
|
@@ -261,18 +290,19 @@ def requeue_superseded( | |
| print(f"::warning::Klaud requeue skipped: ownership unavailable ({type(error).__name__})") | ||
| return [] | ||
| token = os.environ["KLAUD_REQUEUE_TOKEN"] | ||
| comment = translated( | ||
| f"**requeued** · Open for over {STALE_DAYS} days while the published baseline of this " | ||
| "family moved to a newer image. Closed with `klaud-requeue` so a new candidate can " | ||
| "refresh the family from its current image.", | ||
| f"**requeued** · 本 PR 已开放超过 {STALE_DAYS} 天,而该配置族已发布的基线已更新为" | ||
| "更新的镜像。已关闭并标记 `klaud-requeue`,新的候选可以基于当前镜像更新该配置族。", | ||
| ) | ||
| closed = [] | ||
| for pull, candidate in stale: | ||
| for pull, candidate, (english, chinese) in stale: | ||
| if candidate in owned: | ||
| continue | ||
| number = pull["number"] | ||
| comment = translated( | ||
| f"**requeued** · Open for over {STALE_DAYS} days while {english}, so its " | ||
| "validated sweep no longer matches main. Closed with `klaud-requeue` so a new " | ||
| "candidate can refresh the family from main.", | ||
| f"**requeued** · 本 PR 已开放超过 {STALE_DAYS} 天,期间 {chinese},其已验证的" | ||
| "测试已不再与 main 一致。已关闭并标记 `klaud-requeue`,新的候选可以基于 main 更新" | ||
| "该配置族。", | ||
| ) | ||
| try: | ||
| github.write( | ||
| repository, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🟡 (optional) Free slots can sit idle in a wave because the plan reviews mostly candidates that
selectwill then defer for backlog.planstill sorts and truncates with a static backlog.selectnow adds each taken candidate to the backlog. A config one place below FINISHED_BACKLOG_CAP still sorts first, so the truncated batch can be filled with its candidates. Candidates from configs with room fall outside the batch. Fix: order the candidates in plan by modelling in-wave takes the way select does. Each config gets at mostFINISHED_BACKLOG_CAP - backlog[group]candidates ahead of the backlog ones. [also at: inferencex-e2e/infx/klaud/main.py:750 - After this change, producers can be prepared for candidates that select later defers for backlog. Candidates select would take can then be left without producers.]Why this was flagged
In this pass nvidia-master.yaml has 7 counted backlog entries (the PR description says it now starts at or near the cap).
free_slotsis 2, so the batch at__main__.py:885ismin(review_batch_size, 3*2+4)= 10. The sort at__main__.py:884callswave.blockerwith the static Counter, so nvidia candidates are not marked "backlog" and keep their idle-first and cooldown order. nvidia-master has about 145 keys against 47 for amd, so the 10 reviewed candidates can all be nvidia. Inselect,wave.take(__main__.py:750) moves nvidia to 8 after the first pick, and the other nine land inbacklog-deferred-candidates. The second slot stays empty even though amd-master candidates were available but cut off by the truncation. On the base branch the static count let select take both nvidia candidates (the overshoot this PR fixes). Plan and select used the same rule, so no reviewed batch was wasted that way. Nothing in plan models the new in-wave increment.Verification: Trigger: one master config is one below FINISHED_BACKLOG_CAP (8) at plan time, with 2 or more free slots.
plansorts against a static Counter and truncates (main.py:883-885). Inselect,wave.take(candidate)now adds to the backlog (line 750), so later candidates from that config are deferred and a slot stays empty for the wave. On the base, both slots filled, but by going over the cap.