Skip to content

fix(umbp): count SSD keys without snapshotting them - #808

Merged
TianDi101 merged 1 commit into
mainfrom
fix/umbp-ssd-key-count-no-snapshot
Oct 21, 2026
Merged

TianDi101 merged 1 commit into
mainfrom
fix/umbp-ssd-key-count-no-snapshot

Conversation

@TianDi101

Copy link
Copy Markdown
Collaborator

Problem

SsdBackend::OwnedKeyCount() built a std::vector<KvEvent> of every key the SSD tier owns, under PeerSsdManager::mutex_, and returned only its .size().

Several loops call it:

  • A masterless node's metrics loop (PoolClient::PublishNodeStateGauges) every second.
  • The 30 s activity summary.
  • The master heartbeat's key count.

With ~1.2M SSD keys, each call held the mutex ~145 ms. Everything on the SSD tier waits on that mutex: per-key Exists (the default BatchContains takes it once per key), PrepareReadBatch and commits. So once a second the SSD tier stalled for ~145 ms.

In a DRAM+SSD weighted tier (one standalone server, DEP c384 DSv4-Pro), this made sglang's scheduler lookups ~16 ms instead of P0's ~2.7 ms, growing with the SSD key count. PageBackend::OwnedKeyCount() is already just owned_.size(), so DRAM-only deployments never saw it.

Fix

PeerSsdManager::OwnedKeyCount() returns owned_.size() under the lock. SsdBackend::OwnedKeyCount() uses it. The snapshot has exactly one entry per owned_ element, so the count is unchanged.

How it was found

On a live e2e arm, a side client inside the container probed exists (32 keys every 0.2 s). Every ~2.3 s a call stalled 70–165 ms; back-to-back calls stayed ~1 ms.

  • perf sched showed one server thread waking every 1000 ms and running ~145 ms on the CPU.
  • perf record -t on that thread: PeerSsdManager::SnapshotOwnedKeysLocked plus malloc.

Benchmark

Standalone server, mixed tier (DRAM 64 GB : SSD 200 GB, weights 423:1000), seeded with 1.5M 4 KiB objects (1.05M on SSD). The server is otherwise idle, and exists is probed on 32 random keys with 0.2 s gaps. Two interleaved runs each:

server mean p99 calls > 10 ms
before 11.5 / 15.8 ms 130 / 172 ms 9 / 10 of ~95
after 0.19 / 0.15 ms 1.5 / 0.25 ms 0 / 0 of 100

Tests

UMBP ctest (gfx950 build): 55/55. umbp_pool_client_ranges and umbp_cross_node_smoke aborted under -j 8 (RDMA device contention) and passed when rerun serially.

🤖 Generated with Claude Code

SsdBackend::OwnedKeyCount() built a vector of every owned key under
PeerSsdManager::mutex_ just to return its size. A masterless node's
metrics loop calls it every second (the master heartbeat does too), so
with ~1.2M SSD keys every per-key Exists, read and commit on the SSD tier
stalled ~145 ms once a second. In a DRAM+SSD weighted tier that made
scheduler lookups 4-16 ms instead of ~2.7 ms.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
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