Repository navigation
Studio: trim idle polling of training downloads and engine status - #18871
Conversation
The global training download discovery re-armed a 1.5 s GET /api/hub/active-downloads forever, visible or hidden, in every tab. A hidden tab now waits HIDDEN_POLL_INTERVAL_MS (10 s, the regular download manager's hidden pace) and polls at once when shown. The download panel's background GET /api/engines poll parks while the tab is hidden and refreshes when it is shown. Foreground engine pickers keep their cadence. GET /api/engines priced an install of every engine on each call (lock parse, SHA-256, torch metadata walk, spec parsing). The priced plan is now reused until the lock file, Studio's site-packages, Studio's package versions or the engine profile change, and is dropped on any engine job state change, removal or rollback. The install path still plans fresh.
|
@codex review |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…Run settings close (#18984) ## Summary `Chat UI Tests (extra)` fails intermittently on unrelated PRs at the same step of `tests/studio/playwright_model_config.py`: ``` [ui-modelcfg] STEP Hub Run opens run settings on a page loaded at /hub [ui-modelcfg] OK Hub Run kept run settings open on a page loaded at /hub [ui-modelcfg] FAIL: composer could not be focused after the Hub Run settings closed ``` Seen on #18871 (09:37) and #18738 (20:00) today. Neither touches the chat composer or the model picker, and the same suite passes on other runs. The step presses Escape, waits for the run settings to hide, then calls `focus()` on the composer in one `evaluate` and reads `document.activeElement` in a second. The run settings live in the model picker, a Radix `Popover`, which returns focus to its trigger as it closes. A focus move like that, landing between the two calls, makes this single attempt fail even though the composer is focusable. The product behaviour this guards is unchanged: `ChatComposerFocusableContext` lifts the `focus()` gate in the same commit that closes the picker, and a real click focuses the composer regardless. ## Fix The check now retries `focus()` plus the `activeElement` read for up to 5 s (every 250 ms) through the suite's existing `wait_until`, and fails with the same message if the composer never takes focus. A composer that stays gated after the settings close still fails the gate. Only the test changes. ## Testing - `python -m py_compile` and `ruff check --select F` on the driver: clean. - The suites that read this driver (CI wiring and Playwright selftests): 213 passed. - I could not reproduce the intermittent failure locally, so the timing explanation above is inferred from the two CI logs and the picker's focus handling, not observed directly.
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. More of your lovely PRs please. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
download_bytes still re-parsed the ~380 KB lock on every status poll via flashinfer_kernel_wheel, outside the priced-plan memo. [skip ci]
|
@codex review |
1 similar comment
|
@codex review |
|
Codex Review: Didn't find any major issues. Bravo. Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Two polls run in every Studio tab on every route, because
DownloadManagerPanelis mounted by the app shell, and both keep going while the tab is hidden.useTrainingDownloadsre-armsGET /api/hub/active-downloadsevery 1.5 s forever, with no visibility check. That is about 39 requests per minute per tab, visible or hidden, even when nothing is training.useEngines(enabled, true)callsGET /api/enginesevery 30 s, hidden or not. On the backend, every call prices an install of each engine that is not installed and current: it parses the ~380 KB lock, hashes it with SHA-256, walks torch's dependency metadata and parses about 100 package specs. On an idle chat with a model loaded, the run-settings engine picker also polls this route every 3 s while the tab is visible, so the pricing runs about 22 times a minute.Change
features/hub/download-manager/visibility-poll.ts(new): one self-rearming poll chain. Adelay(hidden)callback spaces the runs,nullparks a hidden tab, and showing the tab refreshes right away.restart()replaces a run that is still in flight, so an auth reset never leaves two timers armed.refresh()joins a run that is already in flight.use-training-downloads.tsx: polls every 1.5 s while visible and everyHIDDEN_POLL_INTERVAL_MS(10 s, the regular download manager's hidden interval) while hidden, and polls as soon as the tab is shown. Auth reset, the storage listener and dispose behave as before.use-engines.tsandengine-poll-delay.ts: the background caller parks while the tab is hidden and refreshes when it is shown. Foreground callers (pickers, Settings, the offer dialog) keep their 3 s / 1 s / hidden 30 s timer and get no extra refresh on show.core/inference/engine_install.py:download_bytesreuses the priced plan (lock sizes plus the names Studio provides). The cache key is the lock path and its stat identity (mtime, ctime, size, inode), the compat file's identity, the same site-packages mtime key_studio_packagesuses, Studio's package versions (including torch), the engine profile and the interpreter version. Any engine job state change,removeandrollbackclear it. The install itself still callsinstall_planfresh.Nothing changes in the UI while the tab is visible. A training download that is still running at the next hidden poll gets adopted while hidden, as before, and shows the same panel row and toast when the tab comes back. One case narrows:
/api/hub/active-downloadsonly lists running jobs, so a training download that starts and fails within one hidden interval (10 s, was 1.5 s) is never seen by a hidden tab, and its error row does not appear in the panel on return. The training page still reports the failure itself.Results
Production build, headless Chromium,
/apistubbed, idle on a chat for 5 minutes visible and then 5 minutes hidden. Three runs per arm, requests per minute:/api/hub/active-downloads/api/engines/apiA hidden tab drops from about 43 to about 8 requests per minute. Visible traffic is unchanged. The spread between the three base runs is at most 0.4 per minute.
Backend cost of one warm
GET /api/engines(engine_install.statusfor both engines, the same calls the route makes), on Linux with CUDA, neither engine installed, median of 30 calls, two process runs per arm:download_bytesreturns the same values on both arms (vLLM 4,858,571,804, SGLang 4,027,350,437).Training download adopted while hidden: a training job appears 5 s after the tab is hidden, runs for 25 s, ends as released (
idle) orerror, and the tab is shown 20 s later. The panel and toast sequence is the same on both arms: the row and the "Preparing ..." toast appear while hidden, and when the tab is shown the row either clears (released) or shows the error for 12 s, with the toast dismissed.Tests
studio/frontend/tests/idle-visibility-poll.test.ts(new, 8 tests, fails onmain, which has no hidden interval or visibility refresh): hidden interval and catch-up on show, a single armed timer when the tab is shown during an in-flight poll, an auth reset replacing an in-flight poll, a stale-session poll ending the chain until the next reset, dispose during an in-flight poll, the background engines poll parking while hidden, and the foreground cadence staying the same.studio/backend/tests/test_engine_status_price_memo.py(new, 5 tests, fails onmain): repeated status polls price the plan once, a change in Studio's packages reprices, job state changes andremoveclear the cache while progress updates keep it, a rewritten lock reprices, and the install path never reads the cache.npm run typecheckis clean.test_managed_engines.py,test_managed_engines_rocm.py,test_engine_status_stays_cold.py,test_engine_install_uv_lookup.py,test_engine_atomic_json.py,test_wsl_host.pyandtest_managed_engine_offer.py. The same three ROCm tests fail on both arms (test_amd_refuses_4_bit_before_unloading,test_amd_refuses_a_gpu_device_ordinal_mask,test_a_rollback_never_crosses_gpu_platforms), so they were already failing.test_installer_publishes_bounded_output_before_exitis timing sensitive on a loaded host: across reruns it passed 4 of 4 on head and failed 1 of 4 on base.Follow-up commits
_pinsnow parses each lock once per file identity (mtime, ctime, size, inode).download_bytesstill re-parsed the ~380 KB lock on every status poll throughflashinfer_kernel_wheel, outside the priced-plan memo. Cached vLLMdownload_bytes, median of 30 calls, ABAB on a loaded host (ratios only): base 58 / 57 ms, head 11 / 14 ms (was about 21 ms before this commit); SGLang base 52 / 47 ms, head 11 / 10 ms. Byte values unchanged on both arms. New testtest_lock_pins_parse_once_per_file_identity.removeand trimmed comments that restated the code.Re-measured on real Studio installs
Base and head Studio installs, idle chat tab, 2 minutes visible then 2 minutes hidden, ABAB, requests per minute:
/api/apiStudio regression switchboard (auth, settings, model picker, inference settings, crawl, upstream CI, diffusion imports): no regression, no UI change. Cross-platform staging (Linux, macOS, Windows): green.