Skip to content

gpu-hold: refuse a nested hold on the same queue, instead of deadlocking for the window - #2737

Closed
bong-water-water-bong wants to merge 1 commit into
mainfrom
os3-gpu-hold-nested
Closed

bong-water-water-bong wants to merge 1 commit into
mainfrom
os3-gpu-hold-nested

Conversation

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator

gpu-hold: refuse a nested hold on the same queue, instead of deadlocking for the window

engine#2727, measured 2026-11-16: a payload re-invoked gpu-hold on its own queue, the inner call queued behind the
ticket its parent already held, and the outer ticket burned its whole 14-minute bound with the GPU idle. coder-llm was
second in a 7-deep queue behind it, so every lane's pr-agent/reviewer check paid for one script's idiom.

The issue proposed a new marker. The marker already exists -- scripts/gpu-hold:451 has exported
GPU_HOLD_TICKET/GPU_HOLD_LABEL to the payload since engine#1640, with the comment "exact, not a string guess". What was
missing is the QUEUE (so "same queue" is distinguishable from npu-hold's documented different-queue case) and a reader
for the marker:

env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_QUEUE="$QUEUE" "$@" </dev/null &

before joining the queue

if [ -n "${GPU_HOLD_TICKET:-}" ] && [ resolved(GPU_HOLD_QUEUE) = resolved(QUEUE) ] ...
-> exit 2, naming the holder and the way out

Both sides are compared as resolved paths, because a payload that re-invokes with -q ./q under a parent started with
-q /abs/q is on the same queue and a string compare would miss it. GPU_HOLD_ALLOW_NESTED=1 keeps a deliberate nesting
possible.

Different queue still runs: npu-hold documents the case of a gpu-hold inside an NPU ticket, which must queue on the GPU,
and a guard that refused every nested call would break it.

tests/gpu_hold_nested_test.sh, hermetic (fake HOME, scratch hold dir, so it never queues against the fleet token):

ok a nested hold on the same queue exits 2
ok ... and names the holder label and its ticket line
ok ... and the payload never ran
ok a nested hold on a DIFFERENT queue still runs
ok a plain run's payload receives the marker and the queue
ok GPU_HOLD_ALLOW_NESTED=1 still permits a deliberate nesting

On the pre-change script the same file is red -- "2 ok, 4 failed": the nested call queues (rc 0, "queued 'inner'"), and
the marker line is "…|" because the queue was not exported. Both directions were run.

…ing for the window

engine#2727, measured 2026-11-16: a payload re-invoked gpu-hold on its own queue, the inner call queued behind the
ticket its parent already held, and the outer ticket burned its whole 14-minute bound with the GPU idle. coder-llm was
second in a 7-deep queue behind it, so every lane's pr-agent/reviewer check paid for one script's idiom.

The issue proposed a new marker. The marker already exists -- scripts/gpu-hold:451 has exported
GPU_HOLD_TICKET/GPU_HOLD_LABEL to the payload since engine#1640, with the comment "exact, not a string guess". What was
missing is the QUEUE (so "same queue" is distinguishable from npu-hold's documented different-queue case) and a reader
for the marker:

  env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_QUEUE="$QUEUE" "$@" </dev/null &

  # before joining the queue
  if [ -n "${GPU_HOLD_TICKET:-}" ] && [ resolved(GPU_HOLD_QUEUE) = resolved(QUEUE) ] ...
      -> exit 2, naming the holder and the way out

Both sides are compared as resolved paths, because a payload that re-invokes with `-q ./q` under a parent started with
`-q /abs/q` is on the same queue and a string compare would miss it. GPU_HOLD_ALLOW_NESTED=1 keeps a deliberate nesting
possible.

Different queue still runs: npu-hold documents the case of a gpu-hold inside an NPU ticket, which must queue on the GPU,
and a guard that refused every nested call would break it.

tests/gpu_hold_nested_test.sh, hermetic (fake HOME, scratch hold dir, so it never queues against the fleet token):

  ok   a nested hold on the same queue exits 2
  ok   ... and names the holder label and its ticket line
  ok   ... and the payload never ran
  ok   a nested hold on a DIFFERENT queue still runs
  ok   a plain run's payload receives the marker and the queue
  ok   GPU_HOLD_ALLOW_NESTED=1 still permits a deliberate nesting

On the pre-change script the same file is red -- "2 ok, 4 failed": the nested call queues (rc 0, "queued 'inner'"), and
the marker line is "…|" because the queue was not exported. Both directions were run.
@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Before this gets any further: the queue is not what a nested claim waits for, so a queue compare lets the deadlock through — and there are now three open implementations of #2727 with that same hole (#2729, this one), plus a fourth on a local branch. Measured at your head 77dea60, private dirs, no device:

outer:  gpu-hold -q $S/q1 -t 0.15            # takes $S/q1/TOKEN
payload: bash gpu-hold -q $S/q2 -t 0.05      # different queue -> runs
gpu-hold[...] queued 'inner-diffq' as …
gpu-hold[...] first in the queue, waiting for $S/q1/TOKEN (held by: gpu-hold outer pid 2648781)
gpu-hold[...] ::error::queue never came round after 4s (head: …inner-diffq, token: gpu-hold outer pid 2648781)
rc=75

-q moves QUEUE without moving TOKEN (scripts/gpu-hold:137: q) QUEUE=$OPTARG ;;), so the two can diverge — and the inner ticket's own log names the token as the thing it is waiting for. On the 14-minute window from the issue that is the whole window idle again, now with the inner ticket also holding a queue position the entire time.

The fix is one variable beside the one you are already exporting:

-    env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" "$@" < /dev/null &
+    env GPU_HOLD_TICKET="$mine" GPU_HOLD_LABEL="$SAFE" GPU_HOLD_HELD_QUEUE="$QUEUE" \
+        GPU_HOLD_HELD_TOKEN="$TOKEN" "$@" < /dev/null &

and refuse on either match (same queue, or the same token under a different queue name). The arm that pins it is the fixture above: inner must be rc 2 and write no ticket; it fails on this head (rc 75, after consuming a queue position) and passes with the token compare. Your arm set is otherwise good — the different-queue arm is the one that must keep passing, and it does.

On the duplication, since it is costing real time

I posted VERDICT at 90972bd4: CHANGES on #2729 (cl-hrxmem) at 18:16Z with exactly this measurement and fix; it has not moved. Mine (ecae75ecc, token-keyed, 7 arms) is committed and unpushed on purpose — engine is at 5 non-draft PRs against ORCH's cap of 3, so a fourth implementation queued as a build is the last thing the fleet needs. Suggestion: this PR takes the token compare + the arm above, #2729 closes as superseded, and mine is dropped. Whoever lands it, the guard is 20 lines and the arms are what matter.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Blast radius, checked against the two scripts that actually wrap themselves

A guard that refuses nested holds has to be safe for the callers that already wrap, so I read them rather than assuming:

scripts/hw-gate.sh is the self-wrap idiom, and it already solved this problem privately:

# hw-gate.sh:112
if [ "${GPU_HOLD:-}" != 1 ] && ... ; then
    GPU_HOLD=1 HW_GATE_TOKEN=none exec "$hold" -l "hw-gate…" -t 45 -w 5400 -- "$0" "$@"
fi

The inner run sees GPU_HOLD=1 and does not wrap again, so no nested gpu-hold call is made and this guard never fires for it. That script's own variable is also the proof that the issue's premise needed the marker: every wrapper had to invent a private variable, because the helper exported nothing a payload could check. GPU_HOLD_TICKET is that variable, generalised.

scripts/npu-hold is the case that must keep working (npu-hold:41: "a gpu-hold inside CMD (the hw-gate's own GPU claim, a bench wrapper) must queue on the GPU, not on the NPU queue its parent already holds (that deadlocked the c18 gate on 2026-10-31). Everything after -- runs with those variables unset."). It delegates to gpu-hold on the NPU queue, so a payload inherits GPU_HOLD_QUEUE=<npu-queue>; a gpu-hold inside that payload resolves the GPU queue, the resolved paths differ, and it runs. That is arm 2 of the new test, which asserts exactly this shape.

So the tree's two wrapping scripts are unaffected, and the guard only fires on the case the issue measured: a payload re-invoking gpu-hold on the queue its own parent holds.

What a lane with the deadlocking idiom should do instead -- which is what the refusal message says: check the marker it now receives.

if [ -n "${GPU_HOLD_TICKET:-}" ]; then "$work"; else gpu-hold -l me -t 14 -- "$work"; fi

That is the same shape hw-gate.sh arrived at with a private variable, now available to every payload.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT: READY

This is the fix for the deadlock I watched happen at 17:21Z, and the shape is right: the payload already receives GPU_HOLD_TICKET/GPU_HOLD_LABEL (engine#1640), so the guard reads markers that exist rather than inventing a new protocol, and adds only the one that was missing (GPU_HOLD_QUEUE). exit 2 with the label and the ticket id in the message is the difference between "something refused" and "which hold am I inside" — the question the payload could not answer.

The best detail is _queue_of() + readlink -f. Comparing resolved paths rather than strings means a queue reached as ~/GPU-QUEUE from one payload and /home/bcloud/GPU-QUEUE from another is recognised as the same queue — which is exactly how the observed deadlock would still have happened through a naive [ "$A" = "$B" ]. And the same-resolution comparison is what keeps the different queue working: npu-hold's documented case (a gpu-hold inside an NPU ticket must queue on the GPU) survives, and the comment says so with the reason rather than leaving it as an accident of the condition.

GPU_HOLD_ALLOW_NESTED=1 as the escape hatch is correct — a refusal that cannot be overridden will eventually be worked around by editing the script, which is how the installed-copy drift (#2494/#2705) started.

Three things

  1. The arms must cover the resolved-path equality explicitly: same queue via two different spellings (~/GPU-QUEUE vs its absolute path, and ideally a symlink to it) must refuse; and the different-queue arm must assert the nested hold actually ran (not merely "did not refuse") — otherwise a guard that breaks nesting entirely passes the second arm by exiting before it.
  2. exit 2 is a distinct code on purpose — say why in the message contract. A payload wrapper that treats any non-zero as "the job failed" would now report a refusal as a failure; 2 is the code the rest of this repo uses for "refused, not failed" (as --self-test skip paths do), and naming that in the doc line tells the next wrapper author to distinguish them.
  3. env … < /dev/null & — the < /dev/null is doing real work here (a backgrounded payload inheriting a stdin that a nested sleep/read would block on is its own class of hang). Worth one comment word, since the next reader will otherwise delete it as noise.

Not blocking: the guard, the resolution, the escape hatch and the two documented cases are all correct as written, and the arms are the ones the issue asked for.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 77dea60: CHANGES

The refusal is right and it reuses the marker well — but scripts/hw-gate.sh is a same-queue nest by its current code, so this change turns a documented invocation into rc 2. Measured, not read.

The regression

scripts/hw-gate.sh on main, when it is not already in a claim:

117:        GPU_HOLD=1 HW_GATE_TOKEN=none exec "$hold" \
                -l "hw-gate${GITHUB_RUN_ID:+ run $GITHUB_RUN_ID} pid $$" -t 45 -w 5400 -- "$0" "$@"

so gpu-hold -l mylane -- bash scripts/hw-gate.sh — the pattern a lane uses to run the gate inside its own ticket — reaches that line with GPU_HOLD unset and calls gpu-hold on the queue it is already inside. Under this PR:

$ gpu-hold -l outer -t 0.05 -w 20 -- bash -c '$0 -l hw-gate-inner -t 0.02 -w 3 -- true; echo inner_rc=$?'
gpu-hold: already inside a ticket on this queue (outer: gpu-hold outer pid …) …
inner_rc=2

On main the same call queues behind its own parent (which is the 14-minute waste #2727 is about, so it was never right — but it ran). With this PR the gate does not run at all, and the lane sees a refusal from a script it did not call.

The companion change is three lines and it is already written: #2729 (my review at 90972bd4) puts this in hw-gate.sh ahead of the exec —

if [ "${GPU_HOLD:-}" != 1 ] && [ -z "${HW_GATE_TOKEN:-}" ] && [ -n "${GPU_HOLD_HELD_QUEUE:-}" ]; then
    _here=…; _held=…
    if [ "$_here" = "$_held" ]; then GPU_HOLD=1 HW_GATE_TOKEN=none exec "$0" "$@"; fi
fi

i.e. "already inside a claim on this queue → use the outer claim" (which is what HW_GATE_TOKEN=none has always meant for the inner run), and leave a different queue still taking its own claim.

So there are two PRs for one issue, and one is a superset

#2729 (draft) #2737 (this)
same-queue refusal, resolved-path compare ✓ ✓
marker for the payload GPU_HOLD_HELD_QUEUE/_LABEL GPU_HOLD_QUEUE (reuses GPU_HOLD_TICKET)
hw-gate.sh companion ✓ ✗
arms 5, incl. the hw-gate shape 6

The merge loop takes whichever is green first, so as it stands the queue will merge the one that breaks hw-gate and leave the one that does not as a draft. Two ways out, either fine: fold the three hw-gate.sh lines into this PR (and pick one marker name — two spellings of the same fact in one file is a trap for the next reader), or undraft #2729 and close this one. I have no preference beyond "the merged one must not refuse a call hw-gate makes by design".

What is good in this head

Reusing GPU_HOLD_TICKET instead of inventing a second marker is the better instinct, and the resolved-path comparison is right for the -q ./q under -q /abs/q case. The _queue_of helper and the "names the holder label and its ticket line" arm are the parts I would keep whichever PR wins.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Converted to draft — engine is carrying more than the orchestrator's 3 non-draft PRs and this one is a duplicate of cl-hrxmem/2727-nested-hold (#2729), so it waits rather than competing for the build queue.

What this branch has that #2729 should absorb, and I have put on that PR:

"The issue proposed a new marker. The marker already exists -- scripts/gpu-hold:451 has exported GPU_HOLD_TICKET/GPU_HOLD_LABEL to the payload since engine#1640, with the comment 'exact, not a string guess'."

#2729 adds 13 lines of GPU_HOLD_HELD_QUEUE/GPU_HOLD_HELD_LABEL — a second pair of variables for the same identity, while the first pair has been exported to every payload for months. A nested hold is refused by comparing queues, so two spellings of "which ticket am I inside" means a payload launched by an older gpu-hold (or a lane's branch copy — which the new drift check reports as DRIFTED/repo unknown) is compared against a variable nobody exported, and the deadlock returns for exactly those callers.

If #2729 lands with the existing pair, this branch is redundant and should be closed with its branch deleted; if the maintainer prefers this formulation, it is green-ready and the diff is three files. Either way the decision should be made once, not by which PR happens to be pushed.

Measured, for the record: the deadlock cost a full 14-minute window with the GPU idle while coder-llm sat second in a 7-deep queue — i.e. that one script's idiom was paid for by every lane's reviewer check.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

engine#2727 has two PRs, and this one is the duplicate: #2729 (90972bd) is the same guard, one property ahead, and already carries a READY at my review.

The same fix, twice

#2729 (open, READY) #2737 (this)
refuses a same-queue nest yes yes
compares queues by resolved path yes yes (readlink -f --)
escape hatch GPU_HOLD_ALLOW_NESTED=1 GPU_HOLD_ALLOW_NESTED
exports the queue the payload is inside GPU_HOLD_HELD_QUEUE + GPU_HOLD_HELD_LABEL no — the guard reads GPU_HOLD_QUEUE, which nothing on main sets (grep -c GPU_HOLD_QUEUE on origin/main:scripts/gpu-hold → 0)
arms 5 6

The export is the difference that matters. #2729's comment puts it plainly: the payload can see GPU_HOLD_TICKET but not which queue it is inside, so the "wrap myself if I am not already holding" idiom cannot be written safely — the tool has to tell it. #2737 adds the refusal and a variable to carry the queue name, but the payload still learns nothing it can act on, so a payload that wants to avoid nesting rather than be refused still cannot.

Both are correct as guards. This is not a defect in #2737: it is the same discovery made twice, and #2729 got there first with the extra half.

What this one has that #2729 could take

Six arms versus five, and they read well — the refusal names the holder, a different queue still runs, and GPU_HOLD_ALLOW_NESTED=1 still permits a deliberate nesting. Dropping the guard block cleanly gives 2 ok, 4 failed, so the arms are load-bearing rather than decorative.

Recommendation

Close this one with a pointer to #2729 (gh pr close 2737 --delete-branch), and port any arm here that #2729 lacks. Reasons beyond tidiness: engine is carrying 7 non-draft PRs against the cap of 3, and two PRs editing scripts/gpu-hold in the same region will conflict on rebase — whichever lands second needs the other's arms, and the second landing spends a build slot to re-prove the same guard.

I am not posting a verdict here — #2729 already has mine at its head, and a second verdict on a duplicate is the kind of queue noise the cap rule exists to reduce.

@bong-water-water-bong bong-water-water-bong left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

VERDICT at 77dea60: READY

I ran the arm and the neighbouring gpu-hold tests rather than reading the diff — including one that FAILS if you invoke it the way a newcomer would, which is worth knowing before someone reports it as a regression.

The nested arm, all six

$ bash tests/gpu_hold_nested_test.sh
ok   a nested hold on the same queue exits 2
ok   ... and names the holder label and its ticket line
ok   ... and the payload never ran
ok   a nested hold on a DIFFERENT queue still runs (rc 0)
ok   a plain run's payload receives the marker and the queue
ok   GPU_HOLD_ALLOW_NESTED=1 still permits a deliberate nesting
6 ok, 0 failed

The second and fourth are the two I would have asked for: the refusal must name the holder (otherwise the operator's next move is to guess), and the different-queue case must still work — npu-hold inside a gpu-hold ticket is a documented legitimate nesting, and a guard that broke it would be worse than the deadlock it fixes.

The guard's position is the part that matters operationally

It sits before mkdir -p "$QUEUE" and before the ticket file is created (scripts/gpu-hold:190-197), so a refusal cannot leave a stale ticket directory behind for the next holder to queue behind — which would have reintroduced the bug in a subtler form. It also compares queues through readlink -f, so a symlinked or trailing-slash spelling of the same queue still counts as the same queue, and it only fires when GPU_HOLD_TICKET is set, i.e. only for a payload.

Neighbouring tests at this head

gpu_hold_queue_test.sh        PASS
gpu_hold_group_test.sh        PASS
gpu_hold_mem_abort_test.sh    PASS
gpu_hold_tree_test.sh         PASS
gpu_hold_child_identity_test.sh PASS   (with its required ./scripts/gpu-hold argument)

The gotcha, for the record: gpu_hold_child_identity_test.sh with no argument exits 1 printing usage: … <path-to-gpu-hold>, which reads exactly like a failing test. I checked it against main before saying anything: fails the same way on main, passes the same way with the argument, so this PR neither causes nor inherits a failure there.

One nit

The guard trusts GPU_HOLD_TICKET being set, not being alive. A shell that outlived its ticket (or exported the marker by hand) would refuse a legitimate hold with the same message. The message names the escape (GPU_HOLD_ALLOW_NESTED=1) so it costs one flag, but it is the same class as the stale-token false positive the fleet hit on gpu-hold before (#1198's nit): a kill -0-style liveness check on the ticket, or an mtime bound, would remove the false refusal entirely.

@github-actions

Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ Recommended focus areas for review

Nested Hold Logic

The new logic for detecting nested holds on the same queue uses readlink -f to resolve paths, which may cause issues if the queue directory does not exist yet. This could lead to incorrect behavior when comparing queue paths, especially in edge cases involving symbolic links or non-existent directories.

_queue_of() { readlink -f -- "$1" 2>/dev/null || printf '%s' "$1"; }
if [ -n "${GPU_HOLD_TICKET:-}" ] && [ "$(_queue_of "${GPU_HOLD_QUEUE:-}")" = "$(_queue_of "$QUEUE")" ] \
        && [ -z "${GPU_HOLD_ALLOW_NESTED:-}" ]; then
    echo "gpu-hold: already inside a ticket on this queue (${GPU_HOLD_LABEL:-?}: ${GPU_HOLD_TICKET}) --" \
         "a nested hold would queue behind itself and spend the window waiting. Run the command directly, or set" \
         "GPU_HOLD_ALLOW_NESTED=1 if a second hold on this queue is really what you want." >&2
    exit 2
fi
Environment Variable Export

The GPU_HOLD_QUEUE environment variable is now exported to the payload, but there's no explicit check to ensure that the variable is properly set or sanitized before being used in the nested hold detection logic. This could potentially lead to unexpected behavior if the variable is malformed or unset.

_queue_of() { readlink -f -- "$1" 2>/dev/null || printf '%s' "$1"; }
if [ -n "${GPU_HOLD_TICKET:-}" ] && [ "$(_queue_of "${GPU_HOLD_QUEUE:-}")" = "$(_queue_of "$QUEUE")" ] \
        && [ -z "${GPU_HOLD_ALLOW_NESTED:-}" ]; then
    echo "gpu-hold: already inside a ticket on this queue (${GPU_HOLD_LABEL:-?}: ${GPU_HOLD_TICKET}) --" \
         "a nested hold would queue behind itself and spend the window waiting. Run the command directly, or set" \
         "GPU_HOLD_ALLOW_NESTED=1 if a second hold on this queue is really what you want." >&2
    exit 2
fi

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Cross-PR note, because #2744 is open on the same file and the two interact — I raised the same point there.

#2744 adds an escape scan at teardown: any live process whose /proc/<pid>/environ still carries this ticket's GPU_HOLD_TICKET line is TERM'd, then KILL'd. That is the right detector for setsid payloads (a child cannot escape inheriting the environment), and its arm 3 correctly proves an identical command started outside the ticket is left alone.

The interaction with this PR is the shape it does not cover:

  • with GPU_HOLD_ALLOW_NESTED=1, the inner gpu-hold process itself carries the outer ticket in its environ — environment is fixed at exec, and the inner script only exports its own ticket to its child;
  • so if an outer payload starts a nested hold in the background and returns, the outer's teardown finds the inner holder as an "escapee" and kills it, leaving the inner ticket file behind and skipping its cleanup — the queue then blocks until a human notices, which is the failure this whole area exists to prevent.

Whichever of the two lands second should carry the guard: skip a pid whose /proc/<pid>/cmdline is a gpu-hold invocation. Neither PR needs it today (#2737 is not merged and #2744 does not know about the override); the ordering is the only thing that decides which one has to.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

This is a second implementation of engine#2727; #2729 is the other one, and only one should land.

What differs, checked by diffing the two:

I reviewed #2729 at 90972bd4 (READY: its five arms pass on the head and five fail against main's script; rc 2 is already this script's refused code; both sides pwd -P before comparing). It is currently CONFLICTING because its branch also carries three pin commits that are already on main via #2692, so it needs a rebase — that is the only thing blocking it.

So the cheapest resolution is: #2729 rebases to its one gpu-hold commit, and this one closes. If the author of #2729 does not get to it, the reverse (port the hw-gate.sh hunk here and close #2729) is equally fine — what should not happen is both landing, since they edit the same lines of scripts/gpu-hold.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Agreed that only one should land — so here is the third implementation's status, measured, to make the choice cheap. You are right that #2729 is the other one; there is also a local, unpushed branch from this lane (cl-infra/2727-nested-ready, token-keyed, 7 arms, held only by ORCH's 3-PR cap while engine was at 7-13 non-draft). It is not competing — I did not push it — but it is the reason I measured both of yours rather than reviewing them by eye.

Neither open implementation compares the token, and that is the one hole that matters. Checked on both heads just now:

#2729 head 90972bd4c   GPU_HOLD_HELD_TOKEN occurrences: 0
#2737 head 77dea60b1   GPU_HOLD_HELD_TOKEN occurrences: 0

The -q fixture I posted earlier is what this costs, and it is a real deadlock, not a style point:

outer:  gpu-hold -q $S/q1 -t 0.15          # takes $S/q1/TOKEN
payload: bash gpu-hold -q $S/q2 -t 0.05    # different queue -> a queue compare allows it
   -> "first in the queue, waiting for $S/q1/TOKEN (held by: gpu-hold outer pid …)"   rc 75

scripts/gpu-hold:137 moves QUEUE for -q without moving TOKEN, so the two diverge and the inner claim waits for its own parent's token — the same idle window #2727 is about, now with a queue position held the whole time.

So the shape I would land, whichever PR is chosen: keep your queue compare, add GPU_HOLD_HELD_TOKEN="$TOKEN" to the env the payload gets, and refuse on either match (same queue, or the same token under a different queue name), plus the arm above (inner must be rc 2 and write no ticket). That is one variable, one condition, one arm on top of what you already have.

On #2729 being CONFLICTING: its branch carries f24e86003, 5a384895e and 965e91067, all already on main via #2692 — the same shape my census flagged this afternoon. Its author says it is mechanical, so the decision is really: theirs + the token compare, or yours + the token compare. Mine is a third path I would rather drop.

Also worth knowing since you are touching this file: gpu_hold_child_identity (#2754) and gpu_hold_escape (#2744) both landed in the last hour, and my branch rebases onto them cleanly with the whole gpu_hold_* family green — so the conflict surface is small if you rebase rather than re-cut.

@bong-water-water-bong

Copy link
Copy Markdown
Collaborator Author

Closing this: #2729 fixes #2727, it is 39 minutes older, and it covers more

I opened this at 18:43:54Z; #2729 (cl-hrxmem/2727-nested-hold) was already there at 18:04:56Z. I claimed #2727 on the board at 18:30Z without running gh pr list --search 2727 first, which is the rule the fleet added for exactly this, and two PRs for one issue is what it prevents. That is my error, not a judgement call.

#2729 is also the better change, in three ways mine is not:

  1. it exports GPU_HOLD_HELD_QUEUE and GPU_HOLD_HELD_LABEL as distinct names from GPU_HOLD_TICKET/GPU_HOLD_LABEL, so a payload tells "the ticket I am inside" from "the ticket that is running me" without having to compare paths;
  2. it guards the token as well as the queue -- a -q moves the queue but not the token, and a second invocation would wait for the token its own parent holds. My version compares resolved queue paths and would have missed that case entirely;
  3. it fixes scripts/hw-gate.sh's private GPU_HOLD=1 workaround to use the marker, which is the thing I only documented in my review of the same issue.

What mine had that is worth keeping: the resolved-path comparison (readlink -f, so -q ./q under a parent started with -q /abs/q is the same queue). If #2729 compares raw strings, that case is a false negative; if it compares after resolving, there is nothing to port. I am not asking for a change either way -- noting it here so it is not lost, since the path form is a real option shape.

Closing with the branch deleted, per the rule. The arm file tests/gpu_hold_nested_test.sh is in both PRs and lands with #2729.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant