Exp 269: bound the read, don't predict it (moonshot, rejected) - #304
Conversation
Belief impactLearned
What this changed
|
Ships the read routing exp 265 measured and then rejected, by replacing its admission test with enforcement. Three caps checked against what the query is producing rather than against its history — 64 rows, 64 KB of TEXT/BLOB payload read from the cell length before the copy, and 10,000 VDBE opcodes via a SQLite progress handler — each abort mid-flight into an ordinary worker dispatch, so each holds whether or not the pool's expectation was right. A 1 ms per-event-loop-turn budget answers the microtask coalescing exp 265 had no answer for. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
546855f to
dd252db
Compare
Outcome
Rejected after adversarial review. The small-read latency mechanism is
real, but the candidate's defining safety claim is false. No runtime,
build-hook, diagnostic, or test-only API change remains in this PR; the final
diff is publication-only.
The exact prototype is preserved at
archive/exp-269(
dd252db49a538777f0c23135f2e466be5c12e2a7) for inspection.What the experiment tried
Exp 265 measured that worker-isolate dispatch is most of a hot point read, then
rejected caller-isolate routing because row history could not bound bytes, work
before the first row, or a non-yielding chain of reads.
Exp 269 tried to enforce those bounds during execution instead:
After two small observations, a statement could run synchronously on a
dedicated caller-isolate connection. Crossing a cap reset the statement and
replayed it on a worker.
What held up
The performance mechanism reproduced on the exact final candidate (collection
3, two order-flipped pairs):
The release sweep against the exact parent recorded 1 win, 0 regressions, and
168 neutral metrics. Its sole win was synthetic point-query throughput;
representative chat/feed lanes remained within the declared noise floor.
Collections 1 and 2 used a pre-sentinel decoder implementation. They support
the mechanism but are not extra repetitions of the final runtime.
Why it is rejected
The decisive probe arms this SQL with two one-byte reads, then requests 16 MiB:
It returns one INTEGER, copies no result payload, and remains below the VM-step
limit because the expensive byte generation occurs inside one SQLite function
opcode.
96e6730dd252dbThe database work costs the same. Current main parks the caller on a worker,
so the timer runs; the candidate blocks the calling isolate for 26-28 ms. A
progress handler can request cancellation between selected VM operations; it
cannot preempt a slow function, collation, virtual table, VFS/page fault, or
busy wait inside one operation. Parameter packing and cold preparation also
occur before handler installation, and native TEXT classification can scan a
complete cell before the Dart byte cap.
The audit found additional correctness blockers:
ReaderPool.spawncallers were not all migrated to the extra connection;These are reinforcing defects, but the single-opcode probe alone refutes the
architecture's wall-time premise.
Final package
Kept:
select_inline_opaque_work.dartplus raw candidate/parent/corrected-branch output;Reverted:
lib/,native/,hook/, and inline-routing test change. The finalbranch is byte-identical to
origin/mainin those paths.Validation
dart run benchmark/experiments/select_inline_opaque_work.dart --bytes=16777216 --samples=3on the corrected branch: timer fired before return in all three samples;
dart analyze --fatal-infos;dart test -j 1— 390 tests passed;dart run benchmark/finalize_experiment.dart --experiment=experiments/269-enforced-inline-reads.md;git diff --check origin/main;origin/mainunderhook/,lib/,native/, andtest/.Transferable conclusion
Keep arbitrary-SQL
select()worker-first. A counter or stopwatch around opaquesynchronous work is not preemption. Reopen caller-isolate execution only for an
explicitly restricted/synchronous API or a mechanism that can genuinely yield
inside one SQLite operation.