Skip to content

feat(umbp): SSD demote/promote skip staging; promoting reads land in DRAM; 4 GiB staging preset - #776

Merged
TianDi101 merged 59 commits into
mainfrom
feat/umbp-ssd-direct-migration
Oct 16, 2026
Merged

TianDi101 merged 59 commits into
mainfrom
feat/umbp-ssd-direct-migration

Conversation

@TianDi101

@TianDi101 TianDi101 commented Oct 15, 2026 •

Copy link
Copy Markdown
Collaborator

Why

SSD demotions and promotions copied every byte through the SSD staging arena, the same arena SSD reads use. In the DSv4 e2e (DRAM 100 GB + SSD 600 GB), reads kept the arena full and 1,628 demotions were dropped for want of a staging page. #772 worked around that by capping readers at 7/8 of the arena and sizing it from the tier. This PR takes migrations off staging altogether, so a fixed preset arena is enough and nobody has to tune it.

What changes

1. SSD migrations go through the file, not staging. A new PosixEngine moves bytes between a file and host memory (preadv/pwritev). This keeps the transfer-layer rule: the backend publishes a file range, and an engine moves the bytes.

  • Demote (DRAM → SSD):
    • BatchAllocate(allow_file_ref) reserves a record in the segment log and returns the value's file range. The record gets an uncommitted header, so the log stays parseable.
    • The engine writes the DRAM pages into that range.
    • BatchCommit flips the header to committed.
  • Promote (SSD → DRAM): AcquireMigrationRead(allow_file_ref) pins the key and publishes its file range. The engine reads it straight into the DRAM pages.
  • Pin after commit: the target pin no longer reads the whole value back from the SSD.
  • Who takes this path: the executor asks for a file range only when an engine can join the file to the other side's memory. HBM targets, SPDK tiers and remote writers keep the staged path.

2. A promoting read lands in DRAM once and is served from there.

  • Before: with on_read / on_hits, a read served the key from SSD through staging, then queued a promotion that read the same bytes from SSD again.
  • Now: PeerPool::BatchResolve promotes what the read should promote before it runs (PromoteForRead). The executor reads each key from the SSD file straight into DRAM pages, several keys at once, and the read is served from the promoted copy. One device read, no staging.
  • No room in DRAM: the promotion is skipped and the read is served from SSD as before.
  • High watermark: promotion no longer waits for DRAM to drop below it. The headroom above the watermark exists for this, and eviction, woken after each transition, restores it. With the default promote_mode: copy, demoting a promoted key later is free, since the SSD copy is still there.

3. Staging defaults to a 4 GiB preset, capped at the tier. An explicit staging_slots still wins.

4. Cleanup. The unused SsdCopyPipeline (copy-on-commit DRAM → SSD) is deleted, along with the code only it used: DramCopyPin and PeerSsdManager::Write(segments).

This supersedes #772:

#772 part Here
1/64-of-tier sizing replaced by the 4 GiB preset
7/8 reader cap dropped; demotes no longer stage
local-reader deferral replaced by #762's partial local staging

Staging use after this PR

Config Demote Promote SSD read
DRAM+SSD, promote_trigger: never none n/a staging
DRAM+SSD, on_read none none none, served from DRAM; staging only when DRAM has no room
DRAM+SSD, on_hits(N) none none staging below N hits; the Nth read lands in DRAM
Pure SSD n/a n/a staging; puts stage too

Notes:

  • A GDS read into GPU memory skips staging under every config.
  • Puts that overflow from a full DRAM tier to SSD still stage.

Trade-offs

  • Writes per demoted record: 3 (uncommitted header, value, committed header) instead of 1. In exchange the CPU copies drop from 2 to 0 under O_DIRECT, and the read-back disappears.
  • CRC: records written through the file carry kFlagNoCrc. Ranged reads already skip CRC.
  • Aborted or reaped reservations: they leave a skipped record, i.e. dead space in an append-only log, the same as an evicted record.
  • Promotion runs inside the read call. A promoting read waits for its device reads into DRAM (up to 8 keys in parallel) instead of a staged read. It's one device read either way.
  • RollbackWrite: it now rewinds the append cursor only for the newest record. A failed write can no longer let the next write overwrite a later reservation.

Metrics

  • mori_umbp_backend_medium_events_total{tier="SSD",event="migration_in_place"|"migration_staged"}: the SSD's migration pins (a source being read, or a target after commit), by how they were served.
  • {event="write_in_place"|"write_in_place_aborted"}: reserved records committed, and reservations given up.
  • mori_umbp_client_tier_transitions_total{outcome="promote_failed"}: failed promotions; the read then stays on SSD.
  • PosixEngine traffic appears under engine="PosixEngine" in the transfer metrics.

Built on #775 / #784 (merged in)

Reserved records need #775's segment reclaim to know about them, so this branch merges #784 (which carries #775) and adapts to both:

  • Pinned reservations: a reservation pins its segment, and the replaced record's, until commit or abort, so an emptied segment cannot be deleted while PosixEngine writes into its fd. ReserveRecord takes EnsureActiveSegment's doomed list, and ShardedSsdTier::ReserveRecord refreshes its hints.
  • refactor(umbp): one incremental plan builder shared by every transfer engine #774 (on main): PosixEngine plans through CreatePlanBuilder, with a PosixPlanBuilder keyed by (memory buffer, fd, file offset, direction). PairPlanBuilder keys on host_ptr, which a file does not have.

These were the test-branch-only resolutions of earlier e2e runs; they now live here, so merging the chain in order reproduces the tested tree.

Stacking

Tests

  • New:
    • PosixEngine.RoundTripsScatteredPagesThroughAFile: O_DIRECT and buffered, with zero-padding of the tail checked.
    • test_reserved_records in test_ssd_tier: commit, abort mid-log, and reopen.
    • SsdBackendTest.FileEngineWritesAndReadsWithoutStaging and SsdBackendTest.ExecutorDemotesAndPromotesWithoutStaging: the arena's only page is held by a reader, and the migrations still succeed.
    • PeerPool.ReadPromotesAboveHighWatermarkAndServesFromHotTier: with the hot tier above its high watermark, the read is still promoted and is served from the hot tier.
  • Updated:
    • The sizing test now expects the preset.
    • The tests that used PeerSsdManager::Write now use WriteBatch.
    • The move-promotion test checks that the source is dropped right away.
    • The two master-eviction tests now create the "parked source" with an explicit second reader.
  • Results on the final commit:
    • Affected suites: all pass.
    • Full UMBP suite (-j 8): 51 of 53. The two RDMA integration tests (umbp_cross_node_smoke, umbp_pool_client_ranges) abort under parallel RDMA contention, a known issue, and both pass serially.
    • Flaky GPU case: on an earlier commit, umbp_pool_client_ranges failed once in GpuRangesUseGatherKernel. That was 1 of 7 runs on this PR and 0 of 5 on the base; 4 alternating base/PR runs then passed 8 of 8. It is a known flaky GPU case that has also failed on unmodified main, and this PR doesn't touch the GPU ranges path.
  • Test AReservationKeepsItsSegmentUntilItEnds (test_umbp_ssd_segment_reclaim): an emptied segment survives while a reservation in it is open.
  • After the restack (479c91194): 18 suites pass, among them ssd_backend (37), peer_pool (42), transfer_engine (22), segment_reclaim (13), page_backend (40), component_metrics (22), ssd_tier, sharded_ssd_tier and direct_io.
  • E2E: see the comments.

🤖 Generated with Claude Code

TianDi101 and others added 30 commits October 13, 2026 04:59
Eviction is decided in three places (master EvictKey, PageBackend's
masterless round, PeerSsdManager's after-write round) and freed in two
more ways than the medium's Evict (the page round's own copy of it, and
the SPDK daemon's EvictLRU). The master's request also drops the tier it
measured, so the peer frees by placement and can delete copies nobody
asked about.

The doc lays out the target: the master names (key, tier); PeerPool::Evict
is the one routing entry point both the master and a background local
eviction worker call; MediumBackend::Evict is the only code that frees a
committed key; nothing evicts on the put path.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rees that copy

The master picks victims per (node, tier) but shipped only keys, so the
peer freed by placement: on a tier without on_evict offload it deleted the
key from every backend, and with copy-mode promotion (key in DRAM and SSD)
SSD pressure freed the DRAM copy and left SSD as full as before.

- EvictionVictim{key, tier}: SelectVictims and EvictKeyDispatcher carry
  the tier each victim was charged to.
- EvictKeyRequest gains `repeated TierType tiers = 2`, parallel to keys.
  An older peer ignores it; an older master sends none and the peer frees
  each key from the medium that currently holds it.
- PeerPool::Evict takes PoolEvictRequest{key, tier, backend_id} and frees
  exactly one copy: demote it when it is the placement and its tier has a
  downstream (any trigger -- on_evict vs watermark now only says whether
  the pool also offloads proactively), otherwise drop that copy only. Drops
  run outside the pool lock; lifecycle_mutex_ keeps ClearLocal out.
- A transition that lands on a parked (draining) copy promotes it to the
  durable one, so a later eviction cannot delete it as still-draining.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…rough PeerPool::Evict

Before this, a committed key could be freed four ways: the master's
EvictKey (through PeerPool and the medium's Evict), PageBackend's
masterless round (its own copy of Evict's body, inline on commit),
PeerSsdManager's round (inline after every SSD write, plus
evict-then-retry on a failed write), and tier transitions.  The two
inline rounds bypassed PeerPool -- no on_evict demotion, stale placement,
invisible to InstrumentedBackend -- and the page round ran before the
pool's watermark check, so on a masterless node it deleted the cold keys
the watermark offload was about to move.

Now:
- MediumBackend::Evict is the only code that frees a committed key for
  capacity.  PageBackend::MaybeEvictToLowWatermark and
  PeerSsdManager::EvictToLowWatermark (with its watermarks, after-write
  checks and evict-and-retry) are gone; a write that does not fit fails.
- MediumBackend::EnableLocalEviction is replaced by ordering hooks that
  free nothing: TrackEvictionOrder() and EvictionCandidates(max) ->
  EvictionOffer{key, bytes}, coldest first, skipping leased/pinned keys.
- PeerPool::EnableLocalEviction(backend, high, low) starts one background
  worker.  Commits, NO_SPACE allocations and finished transitions only wake
  it; it takes offers until their bytes cover the overage and calls
  PeerPool::Evict({key, backend_id}, kReclaim) -- the call the master's
  EvictKey makes -- so a tier with a downstream demotes instead of
  deleting.  Lowest tier first, 64 keys per call, with a fixed byte budget
  as well as the live usage check.
- PoolClient enables it for every medium without a master (paged media at
  local_evict_*, SSD at its own watermarks) and for SSD with a master, as
  before.
- A demotion that loses a race to another transition no longer falls back
  to deleting the source, which could abort that transition and lose the
  key.
- mori_umbp_client_local_evict_total{event=round|key|no_candidate|stalled};
  the SSD medium's eviction_round event is gone (rounds are the pool's,
  keys and bytes are InstrumentedBackend's).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With ssd_backend=spdk, PeerSsdManager reaches the device through the
spdk_proxy daemon, whose SpdkSsdTier retried a failed allocation by
dropping its own oldest keys (EvictLRU).  Nothing told PeerSsdManager:
it kept listing those keys, no REMOVE reached the master, and the master
kept routing reads to bytes that were gone.  Fragmentation could trigger
it well below the SSD watermark.

A write that does not fit now fails, as it does on the file tier, and
freeing space is the owner's local eviction, which reaches the tier
through Evict().  PeerSsdManager is the daemon's only client.

Not built by the default dev image (no SPDK); checked with a syntax-only
compile against 3rdparty/spdk/include.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The PR description carries the design; the two code comments that pointed at
the doc already explain themselves.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Same coverage, fewer lines:
- the SSD- and DRAM-scoped evicts of a promoted key share one test, as do
  the stale-tier and backend-scoped evicts;
- the read-recency check rides on the drain test, and the bad-config check
  on the unordered-medium one;
- the mismatched-tier-count case rides on the unscoped EvictKey test;
- the two "writes never evict" cases share one fill;
- dropped VictimCarriesTheTierItWasChargedTo (KeyOverBudgetInTwoTiers checks
  the tier on both victims) and the master-chain SSD-pressure test (the
  parked-source chain test checks the SSD victim end to end, and
  TierScopedEvictFreesOnlyThatMediumsCopy what the pool does with it);
- removed the now-unused Keys() and HasRemove() helpers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Folds #742 into this PR.

- Master: a round frees each (node, tier)'s overage in bytes, optionally
  capped by UMBP_EVICT_MAX_BYTES_PER_ROUND, instead of 32 candidates per
  bucket -- which freed a few MB per round and took hours to drain a
  512 GiB tier's 0.9 -> 0.7 band.  The store returns every eligible row and
  the strategy trims to the budget.
- Peer: PeerPool::Evict queues a demotion on the transition worker instead
  of running the copy inside the EvictKey RPC, so the call never waits on
  bytes.  Each result carries an outcome (freed, demotion queued, in
  flight).  The worker runs an eviction's demotion whatever the tier's own
  watermark says, and drops the copy if nothing downstream can take it.
- Local eviction counts queued demotions toward its budget (a migration pin
  no longer hides a key from EvictionCandidates), so a pass never queues
  more than the overage while the copies run.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… tests

Comments: drop history and restated rationale (the commit message has it).

Tests, same coverage with fewer of them:
- The two GetEnvUint64 tests become one.
- Drop LruMasterEvictStrategy.ABudgetLargerThanAnyRowCapIsMetInOneRound:
  the strategy never had a row cap (the manager did), and it is unchanged.
- The three MasterEvictionBytes tests become one, which also reads the
  limit through UMBP_EVICT_MAX_BYTES_PER_ROUND.
- EvictReturnsBeforeTheDemotionCopyRuns folds into
  OnEvictMigratesBytesToConfiguredBackend, and
  QueuedDemotionsCountTowardTheBudget into the local-eviction demotion test
  (now ATierWithADownstreamDemotesJustTheOverage).
- GatedEngine's hold times out after 10 s, so it needs no ReleaseOnExit
  guard to keep a failed test from hanging teardown.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment-only.  Drops narrative and rationale that restates the code, and
the same "the pool decides, the medium only supplies order" paragraph that
was repeated across several headers; field and helper docs become trailing
one-liners.  Added comment lines across the PR: ~400 -> 195.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
With a master, a node can evict at its own watermarks instead of waiting
for the master's EvictKey rounds, while still taking its victims from the
master's cluster-wide recency.

- Master: new GetEvictionCandidates RPC returns a node's keys on one medium
  (optionally one logical tier), least recently accessed first, until their
  sizes cover the requested bytes; master-leased keys are skipped.
  RegisterClient and every Heartbeat carry peer_driven_eviction, and
  EvictionManager leaves such nodes out of its rounds (in memory only).
  ClientRegistryConfig::advertise_peer_driven_eviction gates both.
- Peer: local eviction asks a candidate source first (at most once per
  200 ms per backend), rounds its value sizes up to the backend's pages,
  evicts through PeerPool::Evict, and covers the rest from the medium's own
  LRU.  In peer-driven mode PoolClient runs local eviction for every medium,
  at a tiered policy's per-tier watermarks when there is one.
- Opt-in: PoolClientConfig::peer_driven_eviction or
  UMBP_PEER_DRIVEN_EVICTION=1, and only once the master confirms support;
  otherwise behaviour is unchanged.  New metric event master_key.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Replaces the peer_driven_eviction switch with PoolClientConfig::eviction_mode
(env UMBP_EVICTION_MODE), which says how a node with a master evicts:

- local (default): every medium at the node's own watermarks, by its own
  LRU, without asking the master.
- master_ranked: the same, with victims ranked by the master
  (GetEvictionCandidates), falling back to local LRU.
- master: DRAM/HBM wait for the master's EvictKey rounds; SSD still evicts
  locally (the previous behaviour).

A self-evicting node (local or master_ranked) asks the master to leave it
out of its rounds; every mode still serves EvictKey, so the master can evict
on demand.  A node without a master evicts locally as before.  Self-evicting
nodes use a tiered policy's per-tier watermarks when there is one.

Tests that fill tiny tiers on purpose (cross-node smoke, tier benchmark)
now run in master mode, the behaviour they were written against.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Two ways a local read of SSD-resident keys failed although every key was
on the device, both seen in the DRAM->SSD demotion e2e run (DSv4-Pro,
sglang direct linker, 300 GB DRAM + 1.5 TB SSD):

* A resolve batch needing more staging than the whole arena failed outright
  ("batch requires 77580 staging pages but arena has 65536; not retryable"),
  however long the caller waited.  The linker's layer-wise reads asked for
  ~2.6k objects per call, so every such call failed.
* Staging was only ever freed by the read lease's expiry (3 s): no local
  reader released it, so the arena had to hold read_rate x 3 s -- ~27 GiB at
  the 9 GiB/s the run reached.

Now:
* SsdBackend::BatchResolve stages at most half the arena per call and
  returns the rest as ResolveOutcome::kDeferred -- held, readable, resolve it
  in a further call.  The first key is always taken, so a batch progresses.
  PeerPool keeps deferred keys' placements; on the wire a deferral is a
  failure (a remote reader cannot come back for the rest).
* MediumBackend::ReleaseResolved hands staging back as soon as the reader's
  copy is done.  Leases are refcounted per published entry and carry a token
  (ResolvedEntry::lease_token), so a shared lease outlives its first reader
  and a release arriving after expiry cannot free the successor's pages.  A
  BUSY resolve drops the holders it took, since the caller discards it.
  Readers that never release (peers over the wire) still expire as before.
* PoolClient's local readers (BatchGetRanges, ServeLocalGets) run resolve ->
  copy -> release in rounds until nothing is deferred; ExecuteLocalGet and
  the two medium existence probes release what they staged.
* InstrumentedBackend counts a kFailed resolve as failed instead of a miss,
  and does not count kBusy/kDeferred (the retry is counted).
* New SSD medium events: staging_early_release, resolve_deferred.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A resolve's read lease protected its bytes for a fixed window (SSD staging
3 s, DRAM/HBM pages 500 ms) whoever the reader was.  For an in-process
reader that is a use-after-free waiting to happen: a copy that outlives the
window has its staging reclaimed (SSD) or its pages evicted (DRAM/HBM) and
reused while it is still reading them.  The timer exists for peers reading
over the wire, which cannot report completion; a local reader can.

BatchResolve now takes a ResolveReader (kRemote by default, the one that
cannot leak).  A kLocal reader always hands its entries back with
ReleaseResolved, and until it does:
* SsdBackend counts it in the lease's local_holders; the reaper skips such
  a lease past expiry (warning once at 30 s overdue).  Remote holders keep
  the old expiry, so a lease a peer touched still waits for its timer after
  the local reader releases.
* PageBackend counts it in the slot's local_readers, which fences Evict,
  eviction candidates and the local reclaimer like a live lease.  Releases
  carry the slot generation as their token.
PoolClient resolves its local reads as kLocal and releases on every path:
the busy retry gives back a discarded response's holds, the read rounds
release from a scope guard, and an existence-only ResolveLocalBatch caller
releases at once.  PeerPool forwards the reader and gains ReleaseResolved.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The transition worker dropped an evicted copy on ANY failed demotion.  That
is right when nothing downstream has room -- the tier must still free -- but
a copy, commit or read-back failure on a target that had room is a fault on
the way, and the evicted copy is the only one: dropping it turned a burst of
3,934 transient SSD write failures into 3,934 lost keys in the e2e run.

TierTransitionResult::retryable marks those failures; the worker requeues
such an eviction demotion (up to 3 more attempts, at the back of the queue,
so it runs after the backlog) and drops the copy only after that, or when no
target had room.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…opping

When a demotion's target answered "no space" the transition worker dropped
the evicted copy at once -- the only copy.  For an SSD target "no space"
only ever means its staging arena is momentarily full of in-flight reads
(BatchAllocate does not check device capacity), so under heavy read load
the e2e run lost 137 keys in one 30 s window, each of which a reader had
just been told was present: its next get failed.

No space at a target is now retryable, and a retryable eviction demotion
is retried for a wall-clock budget (UMBP_EVICT_DEMOTION_RETRY_MS, default
30 s, from its first attempt) instead of a fixed count, which a short queue
burned in milliseconds.  A retry pauses 20 ms only when nothing else is
queued, so it neither spins nor holds up other transitions.  The copy is
still dropped once the budget is spent, or at once when the target can
never take the key, so a source tier always frees.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
`failed` counts every failed transition attempt, including ones a retry
later rescues, so it cannot tell a pressure burst from lost keys.  The
pool now counts each evicted copy it actually drops -- the demotion could
not land within its retry budget, or never could -- as
TierTransitionMetrics::dropped, exported as
mori_umbp_client_tier_transitions_total{outcome="dropped"}.  The activity
summary's "K dropped" comes with #683, which adds that summary.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment-only, plus ProbeLocal for the two resolve-and-release probes that
were written out twice.  ResolveReader now sits above ResolveOutcome's
comment instead of between it and its enum.  The SSD backend tests fold
from eight to five (one shared-lease test, one remote-expiry/stale-token
test) and the PageBackend pair into one.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Comment-only, plus one anonymous namespace instead of two back to back.  The
transient- and persistent-failure tests become one (retried until it lands;
dropped once the budget runs out).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The master ranks a node's keys by last_accessed_at, which only RouteGet
updates.  A local_first node serves its hits without the master, so under
master_ranked (and master) the hottest keys looked the coldest and went
first: in a 4 GB DRAM / 8 GB SSD smoke a hot set re-read throughout the
fill survived 0/512 under master_ranked vs 512/512 under local, and the
hot reads then served from SSD slowed demotion until DRAM sat at 100%.

A node whose eviction follows the master's recency now ships the keys it
reads locally (deduped, bounded) on its heartbeats, and the master
records an access for each.  Local mode sends nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al-leases

Picks up #741's local-read reports; ResolveLocalBatch keeps this branch's probe release and deferred keys alongside them.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Picks up #741's local-read reports.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
master_ranked asked GetEvictionCandidates synchronously inside the
eviction pass, at most every 200 ms per backend.  The in-memory master
answers by scanning its whole index; at e2e scale (500k DRAM + 2.7M SSD
keys on one node) that is 0.66 s per DRAM query and 1.9 s per SSD query,
so a DRAM pass stalled most of every second and every SSD query hit the
1 s deadline and was thrown away after the master had done the work.

The pass now waits at most 20 ms for the query it sends (a small index
still answers the same pass); a slower answer serves a later pass unless
it is over 3 s old, and the medium's own order evicts meanwhile.  One
query per backend is in flight at a time.  The deadline goes to 3 s to
match.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al-leases

Picks up #741's non-blocking ranked queries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Picks up #741's non-blocking ranked queries.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
One pass reclaims a backend's whole watermark band: in the e2e a single
DRAM pass covered 108k keys, while one GetEvictionCandidates answer
carries at most 4096 and arrives after the pass has moved on.  The pass
asked once, at its start, so master_ranked ranked 0 of those 108k
victims (at most 4% even when it used to wait for the answer).

The pass now takes the master's answer whenever it is ready, and asks
again for what the budget still needs as each answer runs out (still at
most one query per 200 ms per backend); the medium's own order evicts in
between.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…al-leases

Picks up #741's whole-pass master ranking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Picks up #741's whole-pass master ranking.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The branch already carries #741's head e8b950a, which bb6af32 squashes
onto 38a4fa3, so the tree is kept as is.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Conflict with #758 in BatchGetRanges: #758 replaced the local_items vector
with an incremental plan builder, and this branch splits the local phase into
resolve -> copy -> release rounds.  Each round now gets its own builder, since
its copies must finish before its holds are released.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TianDi101
TianDi101 marked this pull request as ready for review October 15, 2026 09:10
With on_read / on_hits, a read served the key from SSD through staging and
then queued a promotion that read the same bytes from SSD a second time.
Promotion also waited for DRAM to drop below its high watermark, so it
never used the headroom above it, which exists for exactly this.

PeerPool::BatchResolve now promotes what the read should promote before it
runs (PromoteForRead): the executor reads each key from the SSD file
straight into DRAM pages, several keys at once, and the read is served from
the promoted copy.  One device read, no staging.  A promotion that finds no
room in DRAM leaves the read on the source.  The high-watermark check is
gone; eviction, woken after each transition, restores the headroom.

A move promotion no longer has a read lease on its source, so the source is
removed at once; it is parked only when another reader holds it, which the
master-eviction tests now set up explicitly.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@TianDi101 TianDi101 changed the title feat(umbp): SSD demote/promote go through the file, not staging; 4 GiB staging preset feat(umbp): SSD demote/promote skip staging; promoting reads land in DRAM; 4 GiB staging preset Oct 15, 2026
TianDi101 and others added 9 commits October 15, 2026 09:45
staging_pages_in_use is sampled once per scrape, so a burst that fills
the arena between two scrapes never shows.  staging_pages_peak keeps the
highest occupancy since start, which is what says whether the arena was
ever too small.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ummary

With #683 in main, the activity summary can carry this PR's numbers:
"(N moved, M failed, R retried, K dropped)".  retried counts eviction
demotions re-queued after a retryable failure, so a run shows whether the
retry path is doing anything; it is also exported as
mori_umbp_client_tier_transitions_total{outcome="retried"}.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TierBackend::SpaceStats() reports live bytes, segment files on disk,
files deleted and the bytes they held, and new segments refused because
the filesystem was full.  SsdBackend publishes them as
medium_events_total{event="segment_deleted"|"segment_no_room"},
medium_bytes_total{event="segment_deleted"} and
medium_state{state="live_bytes"|"segment_files"}, so a run shows disk
coming back, and how much of "used" is dead records.  It replaces the
three SSDTier accessors only the tests read, and the refusal count is
now per tier instead of process-wide.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
So a run shows that demotions and promotions really skip staging:
medium_events_total{event="migration_in_place"|"migration_staged"} counts
the SSD's migration pins (a source being read, or a target after commit)
by how they were served, and {event="write_in_place"|"write_in_place_aborted"}
counts reserved records.  tier_transitions_total{outcome="promote_failed"}
splits failed promotions (the read then stays on SSD) from demotions.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
The segment-file tier ranks eviction by its own index, whose recency only
reads through the tier refreshed. LocateRecord, the path GDS reads and
in-place promotions take, did not touch it, so under on_read the SSD
evicted in write order whatever was read. With promote_mode move a load
that promoted a page's c4 objects left their segment mostly dead and still
"cold", so it went next, taking the same pages' indexer objects before the
load read them (an e2e run lost 1,793 of 1,796 keys in one get and sglang
died).

LocateRecord now touches the key like any read.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TianDi101 and others added 5 commits October 16, 2026 09:08
BatchResolve now counts a held-but-unreadable key as status="failed"
instead of a miss, but kProduces still marked resolve/failed as never
produced, so SampleMetrics skipped the series.  Those keys left "miss"
and showed up nowhere: the backend panel read zero resolve failures and
its hit ratio left them out of the denominator.  Mark the pair produced,
so it is published from the first tick like every other series.

Tests: a scripted MockBackend checks that kFailed/kBusy/kDeferred/missing
count as failed/nothing/nothing/miss, and the failed series exists at
zero before its first event.  Both fail with the table unchanged.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…-read-touch

# Conflicts:
#	src/umbp/include/umbp/local/tiers/sharded_ssd_tier.h
#	src/umbp/include/umbp/local/tiers/ssd_tier.h
#	src/umbp/local/tiers/sharded_ssd_tier.cpp
…local-leases

# Conflicts:
#	src/umbp/distributed/pool_client.cpp
A local reader now protects what it resolved by keeping a shared_ptr hold
(ResolvedEntry::hold). The bytes stay put while any hold lives and come back
when the last one drops. This replaces the lease tokens, generations,
ReleaseResolved and kDeferred that the first version of this PR added.

- PageBackend: each committed slot owns a hold. Evict, EvictionCandidates and
  ClearLocal skip a slot whose hold is shared. A kLocal resolve takes no lease.
- SsdBackend: a staging span is reclaimed once its lease has expired and its
  last hold is gone. Reclaim runs in the reaper and on demand when staging is
  full. A kLocal batch is staged up to half the arena at a time; the rest
  comes back kBusy, and the caller serves it in further parts. A kRemote batch
  keeps all-or-nothing staging.
- PeerPool: a partial kLocal batch still touches and promotes what it served.
- PoolClient: ServeLocalGets and BatchGetRanges drop each part's holds before
  resolving the next part. The probes use BatchContains, so they stage nothing.

Also fixes test_peer_pool's FailingEngine to override CreatePlanBuilder
(#774's interface). Before this, test_peer_pool did not build on main.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
TianDi101 and others added 5 commits October 16, 2026 10:19
…irect-migration

# Conflicts:
#	src/umbp/distributed/peer/backend/ssd_backend.cpp
#	src/umbp/distributed/pool/peer_pool.cpp
#	src/umbp/distributed/pool_client.cpp
#	src/umbp/include/umbp/distributed/peer/backend/ssd_backend.h
#	src/umbp/include/umbp/distributed/types.h
#	src/umbp/include/umbp/local/tiers/ssd_tier.h
#	src/umbp/local/tiers/ssd_tier.cpp
#	tests/cpp/umbp/distributed/test_peer_pool.cpp
#	tests/cpp/umbp/distributed/test_ssd_backend.cpp
#	tests/cpp/umbp/distributed/test_transfer_engine.cpp
…ect-migration

Brings in #775 (segment reclaim) and #784, which this PR now merges after.
A reserved record's value is written through its segment's fd outside the
lock, so Reserve/Commit/AbortRecord pin that segment (and the replaced
record's) until the reservation ends, as Write does; a sharded reserve
refreshes its placement hints like a sharded write.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
#774 made Plan() a non-virtual wrapper over CreatePlanBuilder().  PosixEngine
keys plans by (memory, file range, direction) because a file endpoint has no
host_ptr, so it gets its own builder rather than PairPlanBuilder.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
…ce-read-touch

# Conflicts:
#	src/umbp/include/umbp/local/tiers/sharded_ssd_tier.h
#	src/umbp/include/umbp/local/tiers/ssd_tier.h
#	src/umbp/local/tiers/sharded_ssd_tier.cpp
#	src/umbp/local/tiers/ssd_tier.cpp
#	tests/cpp/umbp/local/test_ssd_segment_reclaim.cpp
…-ssd-direct-migration

# Conflicts:
#	src/umbp/distributed/peer/backend/ssd_backend.cpp
#	src/umbp/distributed/pool/peer_pool.cpp
#	src/umbp/include/umbp/distributed/peer/backend/page_backend.h
#	src/umbp/include/umbp/distributed/peer/backend/ssd_backend.h
@TianDi101
TianDi101 changed the base branch from fix/umbp-ssd-staging-local-leases to main October 16, 2026 15:48
# Conflicts:
#	src/umbp/include/umbp/local/tiers/sharded_ssd_tier.h
@TianDi101
TianDi101 merged commit 324d105 into main Oct 16, 2026
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