#7995·buzz

Share Compute (mesh_llm) allocates uncapped Metal shared memory on macOS unified memory, exhausting swap (22-26 GB Untagged footprint)

Author: shanemhamiltonCreated Sep 30, 2026Updated Sep 30, 2026

Describe the bug

When Share compute (mesh_llm) is enabled with the default configuration (maxVramGb: null / "No limit"), buzz-desktop's embedded serving engine (mesh-llm-sdk / skippy-server) queries Darwin hardware capacity on Apple Silicon unified memory systems and allocates uncapped Metal shared memory buffers (SM=SHM).

For curated models like unsloth/Qwen3.8-27B-GGUF:Q4_K_M (15.3 GB weights), skippy-server immediately allocates dozens of contiguous 128.0 MB Metal shared memory buffers for execution context and KV cache (skippy-exact-cache). Under macOS Mach VM accounting, these anonymous shared Metal allocations are categorized by footprint as Dirty Untagged memory.

When buzz-desktop is idle or running in the background, Darwin's VM compressor compresses and writes all ~22 GB of dirty unified memory into disk swap (swapped_out=21.8G), bringing host swap usage to >21 GB and exhausting SSD swap on MacBooks and Mac minis.

Because this was previously observed at 4h 10m uptime with a 22 GB footprint, it was initially suspected to be a ~5 GB/h leak (e.g. unbounded cache, listener, or retained closure). However, VM profiling with vmmap, footprint --vmObjectDirty, and sample proves that the full 22–26 GB is allocated immediately at launch by the Metal serving runtime when mesh-sharing.json is enabled. Disarming mesh-sharing.json ("enabled": false) instantly drops buzz-desktop's footprint from 26 GB to 64 MB.


Steps to reproduce

  1. In Buzz Settings -> Share Compute, enable Share Compute with unsloth/Qwen3.8-27B-GGUF:Q4_K_M, leaving "Max VRAM" blank ("No limit").
  2. Let Buzz initialize or restart.
  3. Inspect memory using footprint <pid> and vmmap -summary <pid>.
  4. Observe 22–26 GB Dirty Untagged memory and >20 GB pushed into swap.

Expected behavior

Share Compute should not allocate 100% of unified memory by default. It should enforce a safe default ceiling (leaving adequate host headroom for the OS, WebKit, and applications) or warn the user before committing >20 GB of Metal buffers that force the host into severe swap thrashing.


Diagnostic Data & Profiling Measurements

1. footprint --vmObjectDirty with Share Compute enabled (unsloth/Qwen3.8-27B-GGUF):

VM Object Dirty Analysis: Enabled
======================================================================
buzz-desktop [54085]: 64-bit    Footprint: 26 GB (16384 bytes per page)
======================================================================

  Dirty      Clean  Reclaimable    Regions    Category
    ---        ---          ---        ---    ---
  26 GB        0 B          0 B        333    Untagged
 155 MB        0 B          0 B         38    Malloc Large
 102 MB        0 B          0 B         41    Malloc Small
  45 MB        0 B        48 MB        192    IOSurface
  23 MB        0 B          0 B          6    WebKit Malloc
8672 KB        0 B          0 B         94    Stack
...
    0 B      15 GB          0 B         47    mapped file
    ---        ---          ---        ---    ---
  26 GB      15 GB        48 MB       9976    TOTAL

2. vmmap -summary excerpt:

Physical footprint:         21.9G
ReadOnly portion of Libraries: Total=3.1G resident=262.8M(8%) swapped_out_or_unallocated=2.9G(92%)
Writable regions: Total=32.4G written=170.3M(1%) resident=3.1G(9%) swapped_out=18.8G(58%) unallocated=10.5G(32%)

REGION TYPE                        SIZE     SIZE     SIZE     SIZE     SIZE     SIZE     SIZE    COUNT
===========                     ======= ========    =====  ======= ========   ======    =====  =======
mapped file                       15.6G     4.6G       0K       0K       0K       0K       0K       48
shared memory                     25.9G     3.0G     3.0G    18.5G       0K       0K       0K      232

3. vmmap -v excerpt showing the contiguous 128 MB Metal buffers (rw-/rwx SM=SHM):

shared memory              710283c000-710a83c000   [128.0M   112K   112K 127.9M] rw-/rwx SM=SHM  
shared memory              710a83c000-711283c000   [128.0M     0K     0K 128.0M] rw-/rwx SM=SHM  
shared memory              711283c000-711a83c000   [128.0M     0K     0K 128.0M] rw-/rwx SM=SHM  
shared memory              711a83c000-712283c000   [128.0M     0K     0K 128.0M] rw-/rwx SM=SHM  
... (230+ contiguous 128 MB allocations following the GGUF blob mmap)

4. Thread stack sampling (sample <pid>):

Thread_1219013: mesh-llm-embedded-serve
Thread_1219014..1219025: mesh-llm-embedded-worker
Thread_1221827: skippy-exact-cache-stage-0
Thread_1221925: skippy-iteration-scheduler
DispatchQueue_785: com.apple.AGXMetal.MemoryPoolDecay

5. Baseline measurement with Share Compute disabled (mesh-sharing.json enabled: false):

======================================================================
buzz-desktop [61385]: 64-bit    Footprint: 64 MB (16384 bytes per page)
======================================================================

  Dirty      Clean  Reclaimable    Regions    Category
    ---        ---          ---        ---    ---
  36 MB        0 B          0 B         22    Malloc Small
6768 KB        0 B          0 B          3    Malloc Large
4864 KB        0 B        16 KB         88    Stack
3504 KB        0 B      4176 KB          6    WebKit Malloc
 688 KB        0 B          0 B        107    Untagged
...
  64 MB      52 MB      4256 KB       9569    TOTAL

Root Cause Analysis & Proposed Fix

  1. Frontend (MeshComputeSettingsCard.tsx): maxVramGb defaults to empty string (""), and the placeholder says "No limit". Toggling Share Compute sends maxVramGb: undefined (null in JSON), which persists to mesh-sharing.json.
  2. Backend (commands/mesh_llm.rs & mesh_llm/mod.rs): restore_mesh_sharing and start_mesh_node accept max_vram_gb: None. When unset, mesh-llm-host-runtime::detect_vram_bytes_capped treats the entire unified memory as available VRAM. On an Apple Silicon Mac with 24–32 GB RAM, skippy-server attempts to claim up to 26 GB of unified memory for model weights, context, and KV cache.
  3. Proposed Fix:
    • Provide a safe default cap for max_vram_gb (e.g. capping at 50% of detected VRAM or reserving at least 8 GB for system/desktop apps).
    • In MeshComputeSettingsCard.tsx, suggest a sensible default VRAM allocation rather than defaulting to unbounded "No limit".
    • Consider auto-disarming or pausing background serving when macOS enters memory pressure or when running on battery / constrained resources.