Skip to content

Budget the dyld classifier in CPU time, not wall clock - #10003

Merged
danielhanchen merged 1 commit into
mainfrom
fix/classifier-budget-measures-cpu-time
Aug 30, 2026
Merged

danielhanchen merged 1 commit into
mainfrom
fix/classifier-budget-measures-cpu-time

Conversation

@danielhanchen

Copy link
Copy Markdown
Member

Backend CI → (Python 3.13) failed on main a6887c5ee:

test_a_pathological_reason_does_not_stall_the_classifier
AssertionError: assert (728.070290015 - 727.064322356) < 1.0

1.006s against a 1.0s budget. Missed by six milliseconds, on a classifier that costs about ten.

Nothing regressed

The caps #8574 added are working. Measured locally, the classifier holds 0.0097s median over seven runs, 0.0168s worst — a hundredfold margin under the budget. The clock was the wrong one.

What the caps buy is that the candidate scan stops being quadratic, and that is a cost in cycles. Wall clock also counts every microsecond the thread is not running, and a hosted runner running the whole backend suite deschedules freely. Pinned to one core, against four spinners on that same core:

run wall cpu
no contention 0.0097s 0.0097s
contended 0.0429s 0.0118s
contended 0.0249s 0.0098s
contended 0.0516s 0.0096s

Identical work. The wall reading moves 5.3x; the CPU reading does not move at all. CI charged the classifier for time it spent waiting for a core.

The change

The assertion measures time.process_time(). The budget stays 1.0 because it was never the problem: healthy is ~0.01s and the regression it guards is 6.3s, two orders of magnitude of room on either side.

It keeps its teeth

Lifting _DYLD_REASON_MAX_CHARS and _DYLD_REASON_SCAN_CHARS to 100M restores the quadratic scan, and the assertion catches it on CPU time at 6.33s — the 6.3s the docstring records:

>       assert time.process_time() - start < 1.0
E       AssertionError: assert (18.279022593 - 11.94483655) < 1.0

Under the four spinners above the whole file passes, taking 25.4s wall for what is normally 6s.

What this does not show

That the old assertion would have failed under that same contention. It would not have: 0.0516s is well inside 1.0s. CI's 1.006s on a 0.01s classifier is roughly a hundredfold inflation, heavier than four spinners on one core reproduce here. The mechanism is what is demonstrated, and it is the only thing that explains a six-millisecond miss on a budget with a hundredfold margin.

studio/backend/tests/test_llama_cpp_start_failure_classification.py: 224 passed.

Backend CI (Python 3.13) failed on main a6887c5:

  test_a_pathological_reason_does_not_stall_the_classifier
  AssertionError: assert (728.070290015 - 727.064322356) < 1.0

1.006s against a 1.0s budget, missed by six milliseconds, on a classifier that
costs about ten.

The caps #8574 added are working. Measured here, the classifier holds ~0.0097s
median over seven runs, 0.0168s worst, which is a hundredfold margin under the
budget. Nothing regressed; the clock was the wrong one.

What the caps buy is that the candidate scan stops being quadratic, and that is
a cost in cycles. Wall clock also counts every microsecond this thread is not
running, and a hosted runner running the whole backend suite deschedules freely.
Pinned to one core, against four spinners on that same core:

  no contention    wall 0.0097s   cpu 0.0097s
  contended        wall 0.0429s   cpu 0.0118s
  contended        wall 0.0249s   cpu 0.0098s
  contended        wall 0.0516s   cpu 0.0096s

Identical work. The wall reading moves 5.3x and the CPU reading does not move at
all. That is the whole failure: CI charged the classifier for time it spent
waiting for a core.

So the assertion measures time.process_time(). The budget stays 1.0s because it
was never the problem: healthy is ~0.01s and the regression it guards is 6.3s,
two orders of magnitude of room on either side.

It keeps its teeth. Lifting _DYLD_REASON_MAX_CHARS and _DYLD_REASON_SCAN_CHARS
to 100M restores the quadratic scan, and the assertion catches it on CPU time at
6.33s, which is the 6.3s the docstring records. Under the four spinners above the
whole file passes, taking 25.4s wall for what is normally 6s.

One thing this does not show: that the old assertion would have failed under
that same contention. It would not have -- 0.0516s is well inside 1.0s. CI's
1.006s on a 0.01s classifier is roughly a hundredfold inflation, heavier than
four spinners on one core reproduce here. The mechanism is what is demonstrated,
and it is the only thing that explains a six-millisecond miss on a budget with a
hundredfold margin.

studio/backend/tests/test_llama_cpp_start_failure_classification.py: 224 passed.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Aug 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-08-30T09:24:42.623625Z 7ac7f9c PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@danielhanchen
danielhanchen merged commit 8849f48 into main Aug 30, 2026
34 of 36 checks passed
@danielhanchen
danielhanchen deleted the fix/classifier-budget-measures-cpu-time branch August 30, 2026 10:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants