Skip to content

get_server_info walks every cache tree on each call #840

Closed

Description

@dkackman

From the 2026-10-11 develop review.

dw_mcp/workspaces.py server_info now fetches /api/caches on every get_server_info call, and that route stat()-walks the whole inductor, triton and quantized trees synchronously (plus a mark_root attempt per cache). The call every MCP session opens with grows with the number of cached kernels.

Failure: a box with tens of thousands of Triton kernel files and a multi-GB inductor cache pays a full tree walk per get_server_info; the MCP summary only needs byte counts.

Fix direction: cache the scan for a few seconds server-side, or compute the per-cache sizes lazily / in a background refresh and serve the last value.

Activity

  1. added
    performanceTiming/perf regression flagged by the regression agent
    target:mini-aiFound against a non-lem server (DW_TARGET=mini-ai); Don triages
    on Oct 11, 2026
  2. dkackman commented on Oct 12, 2026

    @dkackman
    OwnerAuthor

    triage: batch with #838, #839, #840, #841 — all in dw/disk_caches.py and the /api/caches route (clear lock, staging sweep, scan cost, mark_root logging); one fix, one server restart. (claude-opus-5-5 via anthropic)

  3. added a commit that references this issue on Oct 12, 2026
  4. dkackman commented on Oct 12, 2026

    @dkackman
    OwnerAuthor

    Fixed in 5dc3ff4 on develop: scan_all() reuses its result for 5 s (_SCAN_TTL), dropped on any clear/entry delete. Applies to GET /api/caches and so get_server_info. scan() itself is uncached. Tests: reuse until clear; rescan after TTL. Only mark_root calls on the scan path were via _reason (see #841).

    Batch #838/#839/#840/#841, one commit. Tests pass in the source checkout (tests/test_disk_caches.py, test_server.py, test_api_contract.py; OpenAPI doc regenerated for the changed route docstrings). The full suite's 18 other failures are Kandinsky6 tests that fail on develop without this change. Not deployed by me: the driver deploys develop to mini-ai before the tester runs. Server restart needed; no breaking MCP change. Hard to verify over MCP: the race itself (window is milliseconds); verifiable is DELETE /api/caches/ still returning 200/409/400 as before and get_server_info caches summary still present.

    — claude-sonnet-5-5 via anthropic

  5. dkackman commented on Oct 12, 2026

    @dkackman
    OwnerAuthor

    Tester on mps on mini-ai.lan (develop @ 68ba49b), claude-opus-5-5 via anthropic.

    Ran get_server_info twice back to back. Both returned 200 with the caches summary intact and identical: inductor (enabled, clearable), triton (disabled), quantized (with entry_count). Each entry carries bytes, files and disk_free. So the summary didn't regress.

    The fix itself can't be observed here. Every cache on this box is empty (bytes: 0, files: 0 across all three), and triton is disabled on mps. That means a tree walk costs nothing whether or not the 5 s reuse is in place. The failure the issue describes needs a populated inductor or Triton cache, which only lem has. I'm handing this to lem's loop.

    Suggested check on lem: call get_server_info and note the non-zero cache bytes/files. Then call it two or three times within 5 s, using date between calls for coarse timing. The calls should all succeed with the same numbers, and the repeats shouldn't be slower than the first. Clearing caches is only exposed on the server page, not over MCP, so the invalidation-on-clear path stays covered by the unit tests only.

  6. added and removed
    target:mini-aiFound against a non-lem server (DW_TARGET=mini-ai); Don triages
    on Oct 12, 2026
  7. dkackman commented on Oct 12, 2026

    @dkackman
    OwnerAuthor

    Verified on lem (cuda, develop @ 68ba49b) — tester, claude-opus-5-5 via anthropic.

    Ran the check suggested in the mini-ai hand-off, this time against populated caches:

    • get_server_info once, then twice more in a single batch. All three returned the full caches summary with identical numbers:
      • inductor: 66,424,327 B, 1,564 files
      • triton: 97,153,113 B, 2,025 files
      • quantized: 288,113,614,516 B, 140 files, entry_count 18
      • enabled/clearable/disk_free present on each.
    • Wall clock from the date before the first call to the date after the last was 2.19 s. That covers three get_server_info calls plus the agent turn overhead. No call was slow.

    What I couldn't observe: this box has about 3.6k kernel files. At that size a full walk and a reuse within the 5 s window both finish under turn-latency resolution, so this confirms correct and consistent results, not the TTL itself. The TTL and invalidate-on-clear paths are covered by the implementer's unit tests. Clearing isn't exposed over MCP.

    No regression case added: the existing summary shape is already exercised, and the timing isn't measurable at MCP resolution.

  8. added
    status:verifiedTester confirmed the fix via a real MCP call
    and removed on Oct 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions