diff options
| author | eunhhu <[email protected]> | 2026-09-28 00:37:12 +0100 |
|---|---|---|
| committer | eunhhu <[email protected]> | 2026-09-28 00:37:12 +0100 |
| commit | efb3abdf688f75f2d9436b63813cdbd9814cc285 (patch) | |
| tree | b4e909849bb7417a09a9e73173c5508fb26a45ae /docs/design/003-module-contract.md | |
| parent | d074deee541ad137e07de8186f0a1e1ffd6761fe (diff) | |
| download | pure-efb3abdf688f75f2d9436b63813cdbd9814cc285.tar.gz pure-efb3abdf688f75f2d9436b63813cdbd9814cc285.zip | |
Run folds and filters a leaf of their list at a time
A fold ran its block once per item through the interpreter, a call and a
lookup of the item each: counting 100,000 accounts took 4.7 ms and a
per-account rank over them 5.3 s. When every instruction of a fold's
block (or a table's filter) has a lane form, as numbers and indexes with
no branch and no text do, the module marks it at load, and the block
then runs for a leaf's items at once: a value is one per item (a leaf's
column read in place, or computed into a row per stack depth), the
items' positions, or one value for all. Lookups by a value for all items
are made once per fold, not per leaf. Leaves are walked with an iterator
that keeps its path (pure_list_next) and fetches the next leaf ahead.
The lanes only take what the interpreter would compute. Where an item
would fault (division by zero, a non-finite result, a key not found, an
index past the end, a clamp the wrong way round, a fractional move), the
whole leaf runs again item by item, so a fold faults, and a filter leaves
the item out, exactly as before; items join the fold in order, so a sum
adds as it did. lane_folds checks it: 300 rounds of random well-typed
folds in views, in a table's columns reading their row and in a handler
storing them, with a random filter, over random lists, answer bit for bit
as the same module run item by item, 920 faults included by kind and
instruction. list_trees now walks runs too.
On the bank of 100,000 accounts (benchmarks/bank/queries.py), against
the same SQL on SQLite 3.46.1: per-branch totals 16 ms (SQLite 46 ms),
accounts in credit 1.1 ms (6.2 ms), large transfers with their accounts
and tellers 0.77 ms (2.1 ms), each rich account's rank 268 ms (2.85 s),
HTTP and JSON included on Pure's side.
Diffstat (limited to 'docs/design/003-module-contract.md')
0 files changed, 0 insertions, 0 deletions
