Skip to content

Studio: refresh cache sizes that are being re-measured instead of showing the old number - #15718

Merged
danielhanchen merged 5 commits into
mainfrom
fix/cache-inventory-invalidation
Oct 28, 2026
Merged

danielhanchen merged 5 commits into
mainfrom
fix/cache-inventory-invalidation

Conversation

@danielhanchen

@danielhanchen danielhanchen commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #15627.

Before #15627, Settings measured a cache again in the request whenever its last measurement was more than 60 seconds old, so the size shown was always current. #15627 answers a slow cache from its last walk and walks it again in the background. That keeps the page fast, but the page never fetched the new number. A size changed by an install, a training run or a tool outside Studio stayed old on screen until the next visit. This PR closes that gap and a few related ones.

Changes

  • The inventory response has a refreshing flag. It is set when any size came from an expired walk that is being redone.
  • Settings asks again every 2 seconds, at most 60 times, until every size is current. These follow-up reads only swap in the newer sizes: there is no measuring state, and a failed one keeps the rows. They stop when you leave the page, start a newer request or clear a cache.
  • A background refresh queued behind another cache's walk no longer holds its own cache's lock while it waits. A clear, download or Recheck of that cache walks right away.
  • The queued refresh skips itself if a newer size was stored in the meantime.
  • If the background thread cannot start, the read walks in the request instead of serving the old size.
  • Clearing one Hugging Face cache no longer forgets the sizes of the other three. A download or delete still forgets all four.
  • Recheck accepts any walk that began after the click, instead of only one that began after that cache's turn in the request.
  • The memo test fixture waits for background walk threads before restoring the patched state.

Tests

  • Five new cases in test_cache_inventory_walk.py fail on main and pass here:
    • a queued walk does not hold a read
    • a refresh that cannot start walks in the request
    • Recheck accepts a walk begun after the request
    • the refreshing flag
    • clearing one Hugging Face cache keeps the other sizes
  • The new case in cache-rows-model-folder.test.ts fails on main and passes here.
  • Frontend: 13 of 13 tests pass across cache-rows-model-folder.test.ts and settings-cache-purge.test.ts. The typecheck passes.
  • Ten neighbouring cache, hub cache and route test files: main 934 passed, this branch 939 passed.
  • Both show the same single failure, test_cached_gguf_routes.py::test_pipeline_class_guard_passes_every_shipped_family. It is unrelated and already fails on main.
  • py_compile is clean on Python 3.9 and 3.10.

Before and after

Settings > System > Cache files, with a Triton cache whose walk takes a few seconds. The page read the cache once, the cache then grew by 5 GB after the 60 second memo expired, and Settings was opened again. Both shots are taken 25 seconds after opening. Both servers already held the new 5 GB size by then. Before this PR the row kept showing 0 B; with it the follow-up read swaps in 5.00 GB.

Cache files before and after

@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 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-10-28T10:08:36.345602Z 0be805b Manual request
ℹ️ 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

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. You're on a roll.

Reviewed commit: a8126d9033

ℹ️ 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".

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".

@danielhanchen
danielhanchen marked this pull request as ready for review October 28, 2026 09:45
danielhanchen pushed a commit to danielhanchen/unsloth-staging-2 that referenced this pull request Oct 28, 2026
@danielhanchen

Copy link
Copy Markdown
Member Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: 0be805b378

ℹ️ 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".

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".

@danielhanchen
danielhanchen merged commit ed9857c into main Oct 28, 2026
17 of 62 checks passed
@danielhanchen
danielhanchen deleted the fix/cache-inventory-invalidation branch October 28, 2026 11:42
danielhanchen added a commit that referenced this pull request Oct 28, 2026
…rowth (#15822)

## Summary

`Frontend build + bundle sanity` fails on main (seen on #15806, #15799,
#15798, #15795; reproduces locally on `556b28bb40`):

```
eager startup JS: 5837.8 KB raw, 1806.0 KB transfer, 85 chunks
over the startup budget: transfer 1806.0 KB > 1795.7 KB, raw 5837.8 KB > 5819.8 KB
```

Building every frontend commit since the last budget base (`8222149ee`)
and measuring the eager set the same way
`scripts/check-bundle-budget.ts` does:

| commit | raw B | transfer B |
|---|---|---|
| `ed9857c0c3` (#15718) | 5,942,150 | 1,836,750 |
| `39b8a6ce13` (#15678, Trick or treat row) | 5,972,134 | 1,847,702 |
| `556b28bb40` (main) | 5,977,895 | 1,849,311 |

Every other step in the range moves by 0.0 to 0.5 KB. #15678 added
29,984 B raw / 10,952 B transfer in one step and merged without
re-measuring. #15485 then raised the budget by its own 1,953 B, but
measured against `8222149ee`, a base from before #15678, so main has
been over ever since.

## Change

`BUDGET` in `studio/frontend/scripts/check-bundle-budget.ts` is raised
by #15678's measured growth (+29,984 B raw, +10,952 B transfer), with
the measurement recorded next to the earlier raises. Main is then within
budget with 0.5 KB transfer / 11.3 KB raw to spare, so the next
unmeasured growth still fails here.

I tried the gate's first suggestion before raising it. Loading the Trick
or treat dialog on first open (`React.lazy` in `app-sidebar.tsx`) saves
only 10.4 KB raw / 3.0 KB transfer, and it raises the startup set from
85 to 90 chunks: the case the script warns about, where a dynamic import
splits shared modules into extra startup chunks. The rest of #15678's
weight is its Halloween color themes in
`features/settings/lib/color-themes.ts`, which the theme store reads at
startup to apply the saved theme. So that is not a laziness fix, and I
left it out.

## Testing

- `npm run build && npm run bundle:check`: over on main, `within budget
(0.5 KB transfer, 11.3 KB raw to spare)` with this change.
- `tests/bundle-budget-cli.test.ts`,
`tests/bundle-budget-closure.test.ts`: 43 passed.
- Measurements on Node 24.22.1, one machine and build, as the earlier
entries.
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.

1 participant