Research native admission model - kmosoti/FabricO11y GitHub Wiki
Historical report imported 2026-10-10 from
docs/research/native-admission-model.md. Original SHA-256:d6599215d9037168056d9d6bf93594eb343c7489c1db65f2ff72fbde35f9b0b1. Measurements and outcomes retain their stated revisions. Links and local environment labels are normalized;$FABRIC_DATAis the mounted experiment drive. See evidence policy.
Query admission after the native screen
This is a post-measurement research model, not the prospective model used to accept the rejected screen. It proposes a discriminator for a later registered experiment; no third prototype or additional workload is executed here.
Work saved versus work introduced
For one complete first-page invocation, record the number of early key checks
K, avoided literal checks A, and avoided owned-row clones V. Let their
context-dependent costs be c_key, c_literal and c_clone. A first candidate
model for CPU saved is:
saving = A*c_literal + V*c_clone - K*c_key + residual.
The residual includes code layout, branch/cache effects, allocation history and other changed work. It must be measured or bounded before this becomes a useful predictor. Count the joint events directly: matching and key eligibility are correlated through source order and an evolving heap. Multiplying independent predicate and admission selectivities can therefore give the wrong answer.
For the sorted common-literal tail fixture, 1,024 rows match and the selector
holds limit+1 = 65 rows. Source inspection predicts 959 avoidable result clones
once the first 65 matching full keys fill it, assuming the inspected sorted
iteration and window/snapshot conditions. This is a counter prediction for a
future instrumented run, not a directly observed clone count. The screen observed
2,558,531 fewer requested allocation bytes and 11.27% lower primary plain CPU.
Neither number alone identifies a per-clone cost.
For the absent-literal first page, the heap never fills. The key-first mechanism rejects no rows by threshold, so it saves no matching or cloning work while adding admission work. The observed slowdown supports retaining this adversary, but a single pair cannot attribute its entire magnitude to key checking. Owned sealed readers also construct and validate rows before admission; their decoding cost is outside the mechanism's avoidable work.
A monotonic state worth exploiting
The bounded selector (local checkout reference crates/fabric-server/src/query/selection.rs; not present at origin/main) has a
monotonic state transition within a page: unfilled → full. Once full, replacement
does not reduce its length. A possible later strategy is to compute expensive
full-key admission only when a page boundary exists or the selector is full.
For an initial page with no boundary and an unfilled heap, the predicate-first
path avoids constructing keys for nonmatches. After filling, key-first admission
can avoid predicate and cloning work for rows that cannot improve the result.
This does not prove a faster implementation. Checking the state has a cost; callback-based readers may retain a branch per row; the compiler may already eliminate unnecessary key loads. Page continuation still requires the strict canonical boundary before admission. Every selected reader must continue raw digest and typed validation, even for rows rejected by either phase. Equal keys must preserve stable first admission. A branch reduction is never permission to skip corruption detection.
Smallest useful next comparison
Register balanced repeated orders over the same rows, with limits 1, 64 and 2,048; vary absent/matching literals and sorted/shuffled ranks. Keep literal byte positions, field widths, producer bytes and full-answer oracles fixed. Count heap readiness, key evaluations, rejections, literal checks and clones in separate observed builds, and retain plain CPU/wall measurements. Full-capacity and absent cases test introduced work with little or no avoidance. Small filled heaps test actual savings. Hold out an order/seed before choosing any threshold or strategy.
Compare the current baseline, the already rejected unconditional early-admission candidate, and at most one newly registered state-sensitive candidate. Account for observer effects and preparation/validation costs, and retain every adverse population. None of this changes the existing screen's decision or authorizes a new default.