Skip to content

fix(studio): Live Monitor disk usage covers symlinked model storage (#9259) - #9261

Closed
yzxcj797 wants to merge 3 commits into
unslothai:mainfrom
yzxcj797:fix/live-monitor-symlinked-disk-9259
Closed

yzxcj797 wants to merge 3 commits into
unslothai:mainfrom
yzxcj797:fix/live-monitor-symlinked-disk-9259

Conversation

@yzxcj797

@yzxcj797 yzxcj797 commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Closes #9259.

The gap

The /api/system endpoint read only the root filesystem (psutil.disk_usage("/")), so a user who symlinks ~/.cache/huggingface (or points the HF cache setting) at a secondary drive saw the root drive's usage in Settings > Resources > Live Monitor while the models lived elsewhere.

Fix

utils/system_disk.py:system_disk_usage() reads the root filesystem plus the active HF hub cache (get_hf_cache_paths().hub_cache), resolved with os.path.realpath so a symlinked cache is measured on the mount holding the bytes. Volumes are deduplicated by st_dev and summed:

  • cache on the same disk as /: one filesystem, same numbers as before (percent uses psutil's formula);
  • cache on a second drive: the monitor shows root plus that drive;
  • cache directory not created yet: measured at its nearest existing parent;
  • unreadable cache path: the root reading is kept.

The payload shape is unchanged (total_gb, free_gb, percent_used).

Verification

  • studio/backend/tests/test_disk_usage_aggregation.py: 5 tests against the real helper.
  • On a host whose HF cache is on a second volume, /api/system disk went from 2079 GB total (root only) to 32476 GB total (root plus cache volume).

…nslothai#9259)

The system-info endpoint read only the root filesystem's usage. A user
who symlinks ~/.cache/huggingface (or any configured HF cache) onto a
secondary drive sees the root drive's numbers while the models live
elsewhere — the monitor under-reports exactly the storage that matters.

The HF cache root is now resolved through its symlinks (realpath, so the
usage describes the mount holding the bytes, not the one holding the
link) and unioned with the root. Entries dedup by (total, free), so a
cache still under / reports the same single filesystem and the same
numbers as before; a symlinked cache on a second drive adds its bytes.
Verified against the real filesystems on this machine: two same-fs
paths collapse to one, cross-fs paths union (E:/ + C:/ cache -> two
filesystems).

Four tests pin the dedup rule (same rule and key as the endpoint's
aggregator): cache-under-root stays one fs with unchanged numbers, a
second drive adds its bytes, percent blends the union, and the
documented symmetric-mirror edge of the (total, free) key.
@yzxcj797
yzxcj797 force-pushed the fix/live-monitor-symlinked-disk-9259 branch from 99dea85 to 9ac2c65 Compare August 20, 2026 03:12
@yzxcj797

Copy link
Copy Markdown
Contributor Author

Narrowed and rebased off main — the PR is now exactly the disk-usage aggregation in studio/backend/main.py plus tests/test_disk_usage_aggregation.py (single commit 9ac2c65). The diffusion, native_tls, mlx_repair and composer changes are in their own PRs. Suite: 4/4 locally.

@danielhanchen

Copy link
Copy Markdown
Member

Pushed 4bd0c22 on top of a merge with current main:

  • The aggregator returned a dict, but the /api/system payload reads disk.total / disk.free / disk.percent, so every Live Monitor poll would have raised AttributeError and returned 500. The helper now returns a named tuple with those fields.
  • Same-filesystem dedup now keys on st_dev instead of (total, free). Free space moves between two reads while a download is writing, which would have counted the root disk twice.
  • A cache directory that does not exist yet is measured at its nearest existing parent instead of dropping the whole reading to 0.
  • Moved the logic to studio/backend/utils/system_disk.py so the tests exercise the real helper (symlinked second drive, same-volume cache counted once, missing cache dir, unreadable cache, single-disk parity with psutil). Dropped the unrelated test_rag_store.py reformat.

Checked on a host whose HF cache sits on a second volume: /api/system disk went from root only (2079 GB total) to root plus the cache volume (32476 GB total, 2 filesystems).

@danielhanchen

Copy link
Copy Markdown
Member

Closing in favour of #12724. Summing the system disk and the models drive into one number still hid the drive #9259 asks about (a full models drive can read as healthy next to an empty root), and it relabelled the combined total as "System disk" in Storage. #12724 keeps the system disk as is and reports the models drive separately when it sits on another volume. Thanks for digging into this.

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.

[Feature] reflect symlinked model storage on secondary drives for Live Monitor disk usage

2 participants