#1 [high] PR 496 overview: coalesced shared ancestor reads in selene disk_store
PR #496 (FujitsuPolycom, open, ready for review, head f9c9191, base main@c0c4f79). 2 files: selene/src/disk_store.rs (+2803/-913), docs/prefix-cache-offload.md (+5/-1, section 2.4).
Change: splits old InboundRecord (Destination::Device|Host) into
HostInbound(caller-owned buffer path,Staged::read_into, used by CompositeStore/host_inbound): unchangedplan_windows(unaligned).DeviceInbound(GPUStaged::fetch): newplan_aligned_windowssplits on absolute WINDOW_PAGES (64) boundaries;SharedSegment(one disk-thread Open per (path, expected Header), refcounted byusers);SharedWindow(one staged window per (path, expected, first, count, row)) shared across fetches, each follower submits its own GPU upload from the shared staging slots. Also:Owner::Inbound(id,seg)->Owner::HostInbound+Owner::SharedSegment;pump_allnow does outbound, host_inbound, thenpump_device_inbound(passes 1..5e); test-support counters disk_opens/disk_window_reads/coalesced_windows;Staged::in_flight()counts host+device.
Relevant constants: WINDOW_PAGES=64 (selene/src/slab.rs:34 via shared), WINDOWS_IN_FLIGHT=WINDOW_CREDITS=2 (shared/limits.rs:18), RECORDS_IN_FLIGHT=8 (disk_store.rs:64), disk::QUEUE_DEPTH=64.
PR claims: shared Open per file, 64-page aligned coalescing, refcounted windows, demand ordering, failure isolation, Staged::close drains. Evidence: 474 selene tests, Windows IOCP 7 coalescing tests; live SM121 checks; not covered: rerun of single-pass benchmarks after demand-index edit, helios FLARE_RUN_CUDA_TESTS, Windows serving, CompositeStore/PooledStore GPU serving.
Related: #497 (companion, same author, touches Staged::pump_all; merge this first), #477/#486 (other disk_store changes).
Review lens A: correctness and consequences - callers, configs, lifetimes, edge paths.
#2 [high] Research summary
I ran out of budget before finishing the whole review, so this is a partial result stated honestly.
What I reviewed in context
read_charter,AGENTS.md,docs/design-review.mdfor the applicable rules (principle 6 "make storage and lifetimes explicit / never reuse slots while transfers reference them", principle 7 "published checkpoints are immutable", principle 12 "validate the real path").- The whole new device path in
selene/src/disk_store.rs:plan_aligned_windows(700–738),HostInbound(740–997) vsDeviceInbound(1099–1153),SharedSegment/SharedWindow(999–1091),acquire_shared_segment(1362–1402),fail_segment_users/fail_window/apply_shared_disk/apply_device_transfer(1449–1566),find_reusable_window/find_best_existing_window_for/attach_existing_window(1568–1643),build_pending_demand/pick_next_pending_plan(1647–1724),detach_unwinding_windows/sweep_shared_windows/segment_needs_disk_reads(1726–1809),pump_device_inboundpasses 1–5e (1811–2266),pump_all(2268–2289),step/busy/fetch/close(2299–2508), and the consumersDiskStore::apply/fetch/stats(3593–3833). - Supporting code:
selene/src/disk.rs(Open/ReadPages/ReadRow/Closesemantics, FIFO per-id execution,openheader validation),selene/src/slab.rs(SlabPool::allocate/release/free_slots,WINDOW_PAGES),selene/src/geometry.rs(record_slots,row_slots),selene/src/shared/limits.rs(WINDOW_CREDITS = 2), callersselene/src/composite.rs:802–836(hostread_intopath),selene/src/offload.rs:465–650(pool sizing / transport construction),selene/src/shard.rs:1030–1195(per-rankStagedpeers,in_flight()use).
What I checked and found sound
Slot lifetime for a shared window is guarded by followers.is_empty() && disk_referenced == 0 && upload_referenced == 0 (1755–1771); every path I traced that could remove a record or a segment first requires active.is_empty() (Pass 5e, 2213–2230) or refuses to detach while an upload is busy (1737–1741), so apply_device_transfer cannot drop a reply that still holds upload_referenced. allocate(plan.count, plan.row) matches record_slots and the pick_next_pending_plan free-slot precheck, and plan.offset/count index record.pages and win.buffers.pages consistently for aligned windows. Linux disk::Job ordering makes the pending_page_reads/pending_row_reads reply matching correct (jobs for one id run in submission order). Host read_into stays on the unchanged private path, so CompositeStore behaviour is untouched.
Findings
- Nit —
selene/src/disk_store.rs:2485–2506(Staged::close): the timeout diagnostic now sumsoutbound + host_inbound + device_inbound + maintenanceand then.max(usize::from(self.busy())), wherebusy()is a bool. Work held only byshared_segments/shared_windows/ownersis therefore reported as "1 disk transport jobs did not complete" instead of the previousself.owners.len(). Diagnostic-only; fix by counting outstanding disk jobs (owners+ maintenance) so the message stays truthful. - Observation (should confirm) —
selene/src/disk_store.rs:1828–1830with3587and3628: each follower credits the shared window'sread_bytesin full (record.bytes += win.read_bytes), so a coalesced restore still reports its whole chain toDiskStore::apply, which feedsstats.bytes_inandinbound_rate.observe. That keeps the historical definition, butinbound_ratealso priceshit().estimated_secondsfor scheduling. After this change the rate reflects a wall time shortened by sharing, so estimates for a request that will not be coalesced under-report its cost. Not a correctness defect; worth stating explicitly in the description or splitting physical from logical accounting.
Not finished (would settle the remaining risk)
I did not read the new test module past line 8420 (tests staggered_arrival…, different_skip_pages…, private_failure_isolation…, shared_ancestor_failure…, staged_close_drains…), nor #497's pump_all rebase interaction, nor the Windows/IOCP and helios GPU-offload paths. The two-risk areas I would want tests for before approving are (a) a follower attaching to a Read-phase window in a segment that closes in the same pump (my trace says safe via users/settled), and (b) Staged::close draining a coalesced burst within copier::CLOSE_TIMEOUT, which staged_close_drains_active_coalesced_fetches_cleanly appears to cover but which I did not read. I found no blocking correctness defect in the paths I did read.
#3 [medium] Finding 1 (nit): Staged::close timeout diagnostic undercounts
NIT — selene/src/disk_store.rs:2485-2506 (Staged::close, impl DiskTransport for Staged, PR #496 head).
Old code: let abandoned = self.owners.len(); then disk.and(transfers)?; then if abandoned > 0 { return Err(invalid(format!("{abandoned} disk transport jobs did not complete within {:?}", copier::CLOSE_TIMEOUT))) }.
New code:
let abandoned = (self.outbound.len()
+ self.host_inbound.len()
+ self.device_inbound.len()
+ self.maintenance.len())
.max(usize::from(self.busy()));
busy() is now !outbound.is_empty() || !host_inbound.is_empty() || !device_inbound.is_empty() || !shared_segments.is_empty() || !shared_windows.is_empty() || !owners.is_empty() (disk_store.rs:2344-2351). Because the first term is a count and .max(usize::from(bool)) caps at 1, any drain that leaves only shared_segments, shared_windows or owners outstanding reports "1 disk transport jobs did not complete" instead of the previous owners.len().
Why it matters: only the diagnostic; the error is still returned, so the behaviour (retain/leak the pool, fail the close) is unchanged. But the message no longer reflects how many disk jobs are outstanding, which is what an operator uses to size copier::CLOSE_TIMEOUT or to tell a real hang from a slow drain.
Fix: count outstanding disk jobs, e.g. self.owners.len() (as before) or owners.len() + maintenance.len(), before the disk.and(transfers)? and use that as abandoned.