Repository navigation
#783 Query path selection on fan-out, a B+Tree entry-count fix, and a stale-baseline guard for the benchmark report - #786
Merged
Conversation
…plan build PlannerStats resolves the per-archetype index statistics the selectivity estimator reads, and it found them by enumerating ArchetypeRegistry.GetAllArchetypes() and mask-testing each result. That enumerator is a yield-return iterator over the registry's fixed 4096-entry capacity, so every plan build allocated an enumerable and made 4096 interface-dispatched MoveNext calls to locate the one archetype the query's mask already names. It is the right shape for its other callers - schema validation and the Workbench inspector, both once per process - and the wrong one on a path that runs per query. Measured at roughly 3 microseconds per call, flat in entity count: a query matching nothing cost 4.37 microseconds before #629 and 7.87 after, at N=1000, 10000 and 40000 alike. Against a 5 microsecond query that is a doubling, which is what ClusterRegressionBenchmarks.IndexedQuery_1Percent recorded when #665 introduced this method. Bisecting the six regressed benchmarks across fifteen points from 07-03 to HEAD puts every query regression on that one commit and nothing before it, and ablating this method alone recovers the whole fixed delta. The replacement walks archetype ids up to ArchetypeRegistry.MaxArchetypeId, tests the mask first, and resolves metadata only on a hit. The set is identical because Archetypes is indexed BY archetype id - GetMetadata is a plain array read - and a null slot is an unregistered id, exactly what the enumerator skips. Testing the mask before the dereference is also what turns the remaining work into a bit test per id rather than a pointer chase per archetype. IndexedQuery_1Percent goes 10.45 to 7.43 microseconds and OrderedQuery_Take100 12.40 to 9.57 on the same box in the same session. Three hypotheses died first and are worth recording so they are not retried: forcing the pre-#629 scan path back on recovers only about 1 microsecond, so the planner's Path A / Path B choice is not the cause; the transaction floor is 359 against 367 nanoseconds, unchanged; and the cluster geometry is identical on both sides at 64 entities per cluster and 157 active clusters.
…e EntityMap An unfiltered Count() went through CountMatchingCore into EntityMap.CountEntries, which evaluates BroadScanPredicate once per entity over a hash map - about 8 nanoseconds each with random access, so counting ten thousand entities cost roughly 88 microseconds. Since #629 every archetype is cluster-backed and each cluster header already carries the answer for up to 64 entities in one 64-bit occupancy word, so the count is a popcount away: 157 popcounts for ten thousand entities rather than ten thousand probes. PolymorphicQuery_Count goes 149.0 to 1.61 microseconds and ExactQuery_Count 65.2 to 0.99, with allocation falling to the bare transaction floor. The substitution is legal only under four conditions, and each is answered rather than assumed. The occupancy word is CURRENT and knows nothing about the reader's snapshot, so the count is gated on IsClusterFullyVisibleAt - the same per-cluster H1 summary the SoA scan uses, true only when every entity in the cluster was born at or before the reader's TSN and none has ever carried a DiedTSN. It is conservative by construction, so a bail only ever costs performance. Occupancy is liveness and not enabled bits, so any T2 requirement disqualifies the archetype. An entity pending destroy still holds its bit, so a non-empty pending set disqualifies it too. Pending spawns are deliberately NOT a bail: ClaimSlot runs from FinalizeSpawns at commit, so a spawn still pending in this transaction owns no slot and cannot be double-counted against the caller's separate pending pass. The occupancy word is read before the summary and with Volatile.Read, because NoteClusterBorn stores its maximum plainly on the premise that a reader reaches it only after an acquire-ordered read of that word; the other order could pair a fresh maximum with a stale occupancy word. All-or-nothing per archetype, which is a rejection of the obvious hybrid rather than an omission. Counting a cluster that fails the summary would mean EntityMap point lookups at around 80 nanoseconds each, against the 8 nanoseconds per entity of the sequential scan the fallback already performs - so popcounting the clean clusters and probing the dirty ones would be slower on exactly the clusters it was meant to rescue. ClusterAnyDied is never cleared, so a long-lived archetype with churn settles back onto the probe; that is a known ceiling, and the fast path is at its best on read-mostly and freshly loaded data. QueryCountEquivalenceTests forces both strategies through QueryPathProbe.ForcedCount and asserts which one actually ran, because whether the shortcut applies is a property of the data rather than of the query - a fixture that merely counted and hoped would silently become a second probe test the first time a tombstone appeared. Non-vacuity is proven by ablation rather than claimed: removing the visibility gate fails ReaderPredatingACommit_DoesNotCountTheNewEntities, which is a wrong count and not a slow one, along with AfterADestroy; removing the pending-destroy bail fails APendingDestroy.
…er one
ChooseSelectivePath took Path A below 0.05 estimated selectivity, and nothing had ever measured that constant. Forcing each path over 10000 entities across four value distributions and four selectivities, as Path B's time divided by Path A's - below 1.00 means Path B won:
0.1% 1% 5% 20%
Sequential 0.84 0.37 0.17 0.12
Random 0.85 0.45 0.22 0.13
Banded 0.85 0.50 0.25 0.14
LowCard 1.07 1.08 0.99 0.93
The old threshold selected Path A across a band where Path B is 15 to 63 percent faster. Only low-cardinality data favours Path A, by 7 to 8 percent, and its two leftmost cells are one measurement rather than two - with 50 distinct keys, top-10 and top-100 resolve to the same cut-off value. Scattered data was expected to favour Path A on the theory that zone maps cannot prune it; measured, it does not, which is why the sweep covers distributions at all rather than only selectivity.
The reason is structural, not a matter of tuning. Path A range-scans the tree to narrow the candidate set and then throws that narrowing away: its verification loop evaluates every evaluator - including the primary one the tree just answered exactly - through SimdPredicateEvaluator.EvaluateCluster over all 64 slots of every cluster it touched. That is precisely Path B's per-cluster work, so Path A is Path B plus a tree scan whenever the two visit the same clusters, and the ratios above are that tree scan. Making it worth selecting means skipping the primary evaluator during verification, which needs the planner to report whether the scan range exactly implements the primary predicate - true for ordered comparisons, false for not-equal, which KeyRange.Intersect folds into a superset. Until that exists the path stays reachable through QueryPathProbe.Forced, so QueryPathEquivalenceTests keeps proving the two paths agree; what changes is only that production stops paying for the slower one.
ClusterRegressionBenchmarks.IndexedQuery_1Percent goes 6.40 to 5.27 microseconds, against 5.08 before #629 - so with the registry-walk fix this closes that regression - and OrderedQuery_Take100 lands at 7.72 against 8.72 before #629.
ThePlannerDoesNotSelectPathA pins the decision rather than the mechanism, because every other case in that fixture forces its path and none would notice the planner silently reverting - it would only get slower. Its first draft was vacuous and passed at the old threshold too: statistics are published by a background worker on a mutation threshold, so a freshly spawned fixture has none, EstimateClusterSelectivity returns its 0.5 unknown fallback, and the planner takes Path B for a reason unrelated to the constant. It now forces a tick fence and a cluster statistics rebuild first, and fails at 0.05f.
…rced Path A range-scans the primary field's B+Tree to narrow the candidate set and then throws that narrowing away: its verification loop evaluated every evaluator, including the primary one the tree had just answered exactly, through SimdPredicateEvaluator.EvaluateCluster over all 64 slots of every cluster it touched. That is precisely Path B's per-cluster work, so Path A was Path B plus a tree scan whenever the two visited the same clusters - the structural reason it lost at every selectivity on every distribution measured. The plan now carries PrimaryRangeAdmitsOnlyMatches and the verification skips evaluators on the primary field when it is set. The property is one-directional on purpose: a range that is a strict SUBSET of the predicate still qualifies, because skipping an evaluator cannot make a row that was never scanned appear, whereas a range WIDER than the predicate would emit rows only that evaluator was rejecting. KeyRange.RangeAdmitsOnlyMatches therefore declines the four ways ComputeBounds deliberately widens: NotEqual, which cannot narrow a contiguous range at all; strict inequalities on floating types, which stay inclusive because the next representable float is not the threshold plus one in the encoded domain; integer inequalities whose step saturated at the type extent, admitting the threshold itself; and NaN thresholds, where every comparison is false while NaN sorting below negative infinity leaves ComputeBounds handing back a range covering everything. Data-side NaNs need no guard - being below TypeMin they fall outside every range, so no scan yields them. It defaults to false at every other construction site, which is the answer that is always safe: re-evaluating a predicate the range already enforced costs time, skipping one it did not enforce returns wrong rows. Both plan fallbacks leave it false, the full-scan stream because it exists precisely when nothing could narrow and the last-resort branch because it names no field. QueryPathEquivalenceTests is the net, and ablation shows it is not a vacuous one: dropping the exactness guard fails Float and Double and nothing else, which is exactly the pair whose strict inequalities ComputeBounds leaves inclusive - integers pass because their step is exact and NotEqual never reaches the flag, SelectPrimaryStream having declined it. That the ablation fails at all is also the proof the skip executes rather than being dead code. Measured over 10000 entities with both paths forced, Path B time as a fraction of Path A's: low-cardinality data moves from a 7-8 percent tie to Path A winning 1.37 to 1.59 times at every selectivity, while sequential, random and banded are unchanged - there the tree walk itself dominates and removing the per-cluster re-evaluation cannot recover it. So the signal that should drive path selection is key CARDINALITY, not selectivity: few distinct keys with fat AllowMultiple buffers, which is the classification shape. Selection stays off pending that work; this changes nothing in production, where SelectivePathThreshold keeps Path A unreachable, and is the prerequisite for turning it back on.
An AllowMultiple index reported an entry count that grew with the row count instead of the distinct-key count, whenever its keys arrived out of sorted order. Two thousand rows over fifty distinct keys reported 1142. The tree itself was correct throughout — one leaf entry per key, no key twice, every row returned by query — so what drifted was only the counter, which is rule IXS-05.
The cause is that InsertArguments.Added was set as a side effect of reading the value rather than by the sites that create an entry. It is meant to mean "a new leaf entry was created" and it actually meant "somebody read the value", and those differ for exactly one case: a duplicate key on an AllowMultiple index stores its value by appending into the existing entry's buffer, adding no entry at all. That branch reads the value, so it flipped the flag, and the general descent's `if (args.Added) { IncCount(); }` tail counted a key that was never added.
Insertion order decides whether it bites, and that is why it survived. A duplicate whose key is the leaf chain's current last — or its first, or the only leaf — is handled by an OLC fast path that returns before that tail, so ascending inserts counted correctly and every test in the suite built its trees that way. Cyclic keys route through the general descent instead.
The fix gives InsertArguments a side-effect-free accessor, ValueForExistingKey, and uses it at all six duplicate-append sites; GetValue keeps the flag and stays only at the three sites that genuinely create an entry. Five of the six return before the counting tail and were already harmless, and are converted anyway so the invariant holds by construction rather than by which paths happen to read the flag afterwards. Nothing else reads Added: InsertIterative's completed out-parameter is set by control flow, and the unique-constraint check keys on AllowMultiple.
This is not a diagnostic counter. IndexStatistics.EntryCount reports it as the index's distinct-key count, the selectivity estimators divide by it, and the planner chooses both the primary scan stream and the cluster scan path from the result — so every query over such an index was costed from a number that described nothing, and the error grew with the table.
The regression test asserts the leaf chain before the counter, so a tree that really did hold one entry per row fails differently from a tree whose counter drifted; those are different defects with different fixes. Ablating the one live site fails exactly the two cyclic cases and the statistics case, while the four ascending cases and the two degenerate ones stay green — which is the same partition the mechanism predicts. IXS-05 gains its first verifier that exercises the tree rather than the validator: both of the ones it cited are mutants, and that is the gap this fell through.
…lectivity The planner picks between the selective B+Tree scan and the zone-map plus SoA scan again. It last did so below an estimated selectivity of 0.05, a constant nobody had measured, and measuring it found the path 15 to 63 percent slower across the band it selected — so selection was turned off pending an answer to what the right signal is. It is fan-out: rows per distinct key, not selectivity. The two paths pay for different things. The selective scan pays per key in range, a leaf step and a buffer walk each; the full scan pays per cluster it cannot prune, a 64-slot SIMD pass each. Writing keysInRange as matches over fan-out, and giving the full scan its best case of zone maps pruning to matches over ClusterSize clusters, cancels the match count from both sides and leaves fan-out greater than some multiple of ClusterSize. The match count drops out entirely, which is why the old estimate was measuring the wrong property — at a fixed fan-out the ratio between the two paths barely moves across three decades of selectivity. Measured over ten thousand rows with both paths forced, as full-scan time over selective-scan time, on two layouts: keys spread over every cluster so nothing prunes, and keys adjacent so pruning is perfect. Below fan-out 40 the full scan wins on both layouts by between 1.3x and 7x. Above it the spread layout favours the selective scan by 1.18x to 1.84x while the adjacent layout is a wash, between 0.93 and 1.06. The honest reading of that second row is that against perfectly pruned data the selective scan is never a win, so selecting it is a bet that key values and insert order are decorrelated — one that pays 20 to 66 percent when they are and costs about 6 percent when they are not. Fan-out 40 to 80 is marginal enough that two runs of the same cell disagreed in sign, so the threshold sits above that band at two clusters' worth of rows per key, deliberately forgoing a measured win at 125 for being a hair under. Two conditions gate the choice and only the second is a tuning knob. The first is structural: unless the scan range exactly implements every predicate on the primary field, the selective scan must re-evaluate that predicate over all 64 slots of every cluster it touched, which is precisely the full scan's per-cluster work — leaving it as the full scan plus a tree scan, unable to win at any fan-out. Both inputs are read live, from the tree's own entry count and the archetype's EntityMap, and that matters for more than speed. The estimate this replaces was published by a background worker on a mutation threshold, so a freshly spawned fixture had none, the estimator returned its unknown fallback, and a test that checked which path the planner took passed at any threshold. There is nothing to force current now. The row count comes from the EntityMap rather than from active clusters times cluster size, because the latter is an upper bound and dividing it by the key count inflates fan-out by the reciprocal of cluster occupancy — an archetype left ten percent full by destroys would read as ten times the fan-out it has and take the selective scan into the band where it loses outright. No tracked benchmark had this shape. The three indexed fixtures in the suite are a unique index, an eight-key index over a hundred rows, and a two-hundred-key index reached through Count, so none of them crosses the threshold and a regression in the newly reachable path would have been invisible. IndexedQuery_HighFanOut covers it, and PathCardSweepBenchmarks is the instrument the constant came from — re-run it before changing that constant. End to end, with only the selection change differing and both runs back to back, that benchmark goes from 26.27 to 18.66 microseconds while every other benchmark stays within a noise floor whose median is zero.
The report compares each benchmark against the immediately previous run and never checked how old that run was. `min_runs_for_trend` is 1, so a single run of any age became the yardstick: the 2026-08-11 report judged itself against 2026-07-03 and flagged twelve regressions across thirty-nine days and many commits. Three of those twelve were investigated in depth and all three dissolved when the same comparison was re-measured in one session. `DeleteEntity_SingleComponent` went from +38.8 per cent to about +10 once measured against its own parent commit; `Insert_Sequential` and `Lookup_Hit` turned out never to have regressed at all. That is a quarter of the flags and several hours of investigation, and the report gave no hint that its baseline was five weeks stale — the number of days simply was not printed anywhere. The bias is one-directional, which is what makes this worth a guard rather than a caveat in a skill file. Machine state and unrelated commits both accumulate against the newer run, so a stale baseline can only ever manufacture regressions; it can never hide one. Treating those numbers as findings is therefore not conservative, it is wrong in a predictable direction. A comparison whose baseline is older than `max_baseline_age_days` — seven by default — is now reported as `stale_baseline` instead of as a regression or an improvement. The delta is still shown, in its own section and with the column labelled as not a verdict, because it is information; what it is not is grounds for opening an investigation. The exit code counts only real regressions, so a stale baseline never fails a build: "we do not know" is not "something broke". The age itself is now in the report header and the console summary, marked STALE past the limit, and a caution block says what to do instead. Regenerating the 2026-08-11 report through this turns twelve regressions into zero and ninety-one withheld, over a header reading "Baseline age: 38.8 days (STALE)" — which is the line that would have ended each of those three investigations before it started. Omitting the key from config disables the guard, so the CI reference box keeps its current behaviour if that is ever wanted; its baseline is fresh by construction, since it runs per labelled PR.
…aseline is old Adding the age guard and then re-baselining immediately produced twenty-eight regressions against a baseline ONE DAY old. Among them: `EpochGuard.EnterExit` at +29.5 per cent, `EpochGuard.MinActiveEpoch_WhilePinned` at +36.8, `AccessControl.SharedLock_Uncontended` at +25.7 — nanosecond concurrency primitives that the diff in question (a B+Tree accessor, query path selection, and this script) cannot reach by any mechanism. The report header said why: .NET 10.0.10 on the baseline run, 10.0.11 on the new one. The runtime was patched between them, which moves every primitive in the suite at once. So age was only ever a proxy for the question that matters, which is whether anything OTHER than the code changed. A runtime upgrade invalidates the comparison on day one; a different CPU or OS would do the same. The run record already carries all three fields and nothing was reading them. A baseline whose `dotnetVersion`, `cpu` or `os` differs from the current run is now withheld exactly as a stale one is, with the reason naming the field and both values, so the report says "dotnetVersion changed: 10.0.10 -> 10.0.11" instead of leaving a reader to notice two version strings six lines apart in the header. The withheld section gains a column for that reason, since two different causes can now put entries in it. On the run that prompted this the effect is twenty-eight regressions to zero, with a hundred and forty-six withheld under a single named cause. The environment check runs BEFORE the age check because it is the stronger statement: a same-day baseline on a different runtime is no more comparable than a five-week-old one on the same runtime, and reporting the age alone would have implied the comparison was sound.
…k that can be missed The persistent c6id box stops itself after two idle minutes, and the only thing that started it again was a `workflow_job:queued` webhook reaching a Lambda that calls ec2:StartInstances. That is a single delivery with no backstop on the start side, and on 2026-08-12 it was missed: aws-gate-selfhosted sat queued for eight hours against an offline runner, while every ubuntu-latest job in the same workflow run got its webhook normally. The box had to be started by hand, after which the gate passed in two minutes. The webhook itself is fine — the delivery from the previous push twenty-eight minutes earlier returned 202 and "starting i-0b7b66d9dd6f0c6b8", and the label filter correctly ignores the hosted jobs. What failed is that no queued event for the gate job was ever delivered. The likely trigger is this workflow's own concurrency block: a second push cancels the in-flight run mid-lifecycle, and the queued event for the replacement gate job goes missing somewhere in the cancel-and-requeue. Rapid successive pushes are therefore precisely when the toggle is least reliable, which is precisely when a pull request is being iterated on. So the workflow now asks for the box itself rather than hoping something noticed. A new wake-gate-runner job carries the same condition as the gate, and calls start-instances with the credentials two other workflows already use. The webhook stays as the fast path — it fires before this job is even scheduled, so the box is normally already resuming by the time this runs — and this is the guaranteed one. start-instances is idempotent, so the two racing costs nothing, and the job exits immediately when the instance is already running or pending. It retries across `stopping`, which is the one state start-instances rejects and a state the idle-stopper can genuinely leave the box in for a few seconds when a push lands just as it gives up. Failing the job for a condition that resolves itself in ten seconds would trade one false alarm for another. Deliberately not a `needs:` of the gate. A wake failure has to be loud, because it means the gate is about to hang — but blocking the gate on it would turn a transient AWS hiccup into a skipped required check, and a gate that did not run reads worse than the hang it was meant to prevent. The instance id comes from the GATE_RUNNER_INSTANCE_ID repository variable rather than being written into the workflow, and its absence is reported as an error rather than silently starting nothing.
… merely correlates with it Telemetry_EntitiesProcessed_RecordedForQuerySystem failed the gate twice — once on main, once on a branch — with "Expected: greater than or equal to 2, But was: 1", while passing every time locally. It waited for the wrong thing. executeCount is incremented inside the system body, part-way THROUGH a tick, whereas TotalTicksRecorded only moves once a tick has finished being recorded. SpinUntil therefore returned while tick two was still in flight, Shutdown cut it short before its telemetry was written, and the ring held a single tick. Nothing about the engine was wrong; the test asserted a postcondition it had never waited for. A proxy wait is green on the machine it was written on by construction, which is why this never reproduced on a dev box and cost two gate runs on a billed instance to see. Both tests now wait on the quantity they assert. StrictTickAbortTests already did this correctly, so the pattern was in the suite already. DagSchedulerTests.Telemetry_TickDuration_Recorded carried the identical shape — waiting on CurrentTickNumber, which advances when a tick STARTS, before asserting TotalTicksRecorded, which advances when one finishes. It had not failed yet. It is fixed here rather than after it does.
…which script launches a suite Seventeen merge-gate failures in the week to 2026-08-12, and almost none of them needed a billed instance to find. Nine were policy jobs on free runners — rule coverage, invariants, closing-keywords — and every one of those is a Python script already in this repository, costing seconds. Five more were a single known bug, #774, reaching the gate through test/Typhon.Workbench.Tests: a project the documented local workflow never mentions, so nobody had ever run it here. Two were one flaky test. The gate is not doing anything exotic; the only reasons its failures surface on AWS are that the local loop stops at the engine project and stops at Debug. scripts/pre-push.sh closes that. It runs the six policy scripts, then both test projects in Release under the gate's own category filter, and labels each step with the gate job it corresponds to so a local failure reads as the failure CI would have reported. A --policy tier runs just the free checks in seconds. It is not installed as a hook — that is the developer's choice, and the instructions are in the file. What it deliberately does not reproduce is the sharding and the serial Sensitive pass, because those change contention rather than coverage; the file says so, and says which tool to reach for when a test passes locally and reddens the gate anyway. The Workbench suite also ran with no category filter at all. The engine suite gets its exclusions from shard.py's GATE_EXCLUDED; the Workbench run is a bare dotnet test and honoured nothing, so a [Category("Quarantine")] test in that project would have executed and reddened the gate regardless of being quarantined. That is exactly the hole the comment above SENSITIVE_FILTER warns about — the one filter in the run that ignores GATE_EXCLUDED is how an excluded test gets back in — and it was live. shard.py grows a `filter` subcommand that prints the exclusion, and run-gate.sh and pre-push.sh both read it, so there is one definition of "excluded from the gate" rather than three that drift. Quarantine should be a property of the repository, not of which script happens to launch the suite.
This was referenced Aug 12, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Six commits from one investigation into the 2026-08 query regressions. Three closed real regressions, one fixed an engine defect found along the way, one re-enabled a query path on a measured signal, and the last stops the tool that started all this from doing it again.
What is in here
22884660PlannerStatswalked all 4096 registry slots through an allocating iterator on every plan build — ~3 µs against a ~5 µs queryf3d675c6Count()sums cluster occupancy popcounts instead of walking the EntityMap per entity6fbf43cb9d053866678797de74e191dd501a9c19Measured effect
PolymorphicQuery_CountExactQuery_CountIndexedQuery_1PercentOrderedQuery_Take100IndexedQuery_HighFanOut(new)The last row is a same-session A/B with only
EcsQuery.csdiffering. Every other tracked benchmark stayed within a noise floor whose median is 0.0 % — measured by running the identical binary twice.#783 — the entry count
IBTreeIndex.EntryCountreported a value that grew with the ROW count instead of the distinct-key count: 2 000 rows over 50 distinct keys reported 1 142. The tree was structurally correct throughout — one leaf entry per key, no key twice, every row returned by query. Only the counter drifted, which is rule IXS-05.InsertArguments.Addedwas set as a side effect of reading the value rather than by the sites that create an entry, so the duplicate-key branch — which reads the value to append into the existing key's buffer — flipped it, and the general descent'sif (args.Added) { IncCount(); }counted a key that was never added.Insertion order decides whether it bites, and that is why it survived: a duplicate landing on the leaf chain's current last (or first, or the only leaf) is handled by an OLC fast path that returns before that tail, so ascending inserts counted correctly and every existing test built its trees that way.
This is not a diagnostic counter —
IndexStatistics.EntryCountis what the planner reads as the index's distinct-key count, so every query over such an index was costed from a number that grew with the table.Fan-out, not selectivity
The two cluster scan paths pay for different things: the selective scan per KEY in range, the full scan per CLUSTER it cannot prune. Writing
keysInRange = matches / fanOutand giving the full scan its best case cancelsmatchesfrom both sides and leavesfanOut > k × ClusterSize. The match count drops out entirely, which is why the selectivity estimate this replaces was measuring the wrong property.Measured over 10 000 rows with both paths forced, full-scan time ÷ selective-scan time:
The honest reading of the second row: against perfectly-pruned data the selective scan is a wash, never a win. Selecting it is a bet that key values and insert order are decorrelated — which pays 20–66 % when they are and costs ~6 % when they are not. Fan-out 40–80 is marginal enough that two runs of the same cell disagreed in sign, so the threshold sits above that band, deliberately forgoing a measured 1.20–1.84× at fan-out 125.
Both inputs are read live, from the tree's own entry count and the archetype's EntityMap. That kills the old trap where statistics were published by a background worker, a fresh fixture had none, and a path-selection test passed at any threshold.
No tracked benchmark had this shape — the three indexed fixtures are fan-out 1, 12.5 and 25 — so
IndexedQuery_HighFanOutwas added. Without it the newly-reachable path would have had no coverage at all.The stale-baseline guard
The report compared each benchmark against the immediately previous run and never checked its age.
min_runs_for_trendis 1, so a single run of any age became the yardstick: the 2026-08-11 report judged itself against 2026-07-03 and flagged twelve regressions across 39 days.Three of the twelve were investigated in depth and all three dissolved when re-measured against their own parent commit in one session —
DeleteEntity_SingleComponentwent +38.8 % → ~+10 %, andInsert_Sequential/Lookup_Hithad never regressed at all.The bias is one-directional, which is why this is a guard and not a caveat: machine state and unrelated commits both accumulate against the newer run, so a stale baseline can only ever invent regressions. Regenerating the 2026-08-11 report through this turns twelve regressions into zero and ninety-one withheld, under a header reading
Baseline age: 38.8 days (STALE).The delta is still shown, labelled as not a verdict. The exit code counts only real regressions, so a stale baseline never fails a build.
Tests
14 new tests.
BTreeEntryCountTests(9,[VerifiesRule("IXS-05")]) asserts the leaf chain before the counter, so "one entry per row" fails differently from "counter drifted"; ablating the fix fails exactly the two cyclic cases and the statistics case while the four ascending and two degenerate ones stay green — the partition the mechanism predicts.QueryPathSelectionTests(5) covers the threshold, the threshold minus one row, a unique index, an inexact range at high fan-out, and an empty archetype; the threshold pair is self-proving, and ablating the exactness gate fails exactly the inexact-range case.IXS-05 gains its first verifier that exercises the tree rather than the validator — both it previously cited are mutants, and that is the gap this defect fell through.
Full suite green but for the three known
[Category("Quarantine")]reds (#400 ×2, #774), confirmed pre-existing by stashing the change and running unmodified HEAD.check-rule-scopes,audit-rule-coverage(0 blocking) andcheck-doc-linksall pass.Docs branch of the same name carries the ADR-063 correction: its "no signal" rows for destroy and unindexed writes were real, and the harness was why they looked like noise.