Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
f6a76c3
perf(spiraldb): build no source-info tokens for a read that returns n…
eywalker Nov 25, 2026
42cb6fe
chore(dev): fix type errors in the ITL-1464 measurement scripts
eywalker Nov 25, 2026
0f9bcd4
docs(dev): streaming design for ITL-1464
eywalker Nov 25, 2026
611f72c
docs(dev): views design for ITL-1464
eywalker Nov 25, 2026
2818eba
feat(core): row spool, rows fetched by number from memory and local d…
eywalker Nov 25, 2026
aa339d2
feat(operators): streaming join kernels hold join keys and spooled ro…
eywalker Nov 25, 2026
b6796d1
perf(core): carry source-info tokens as a recipe until their text is …
eywalker Nov 25, 2026
3e0794d
feat(core): uniqueness certificates derived per stream, and Join, Mer…
eywalker Nov 25, 2026
4876287
test(operators): keys-only joins against the sync rows (ITL-1464)
eywalker Nov 25, 2026
f37442e
perf(streams): bounded view for run() over an on-demand source (ITL-1…
eywalker Nov 25, 2026
a602768
docs(dev): async join measurements script (ITL-1464)
eywalker Nov 25, 2026
614e5f7
perf(pipeline): keep async rows as Arrow chunks, not object pairs (IT…
eywalker Nov 25, 2026
9f8f0b5
docs(dev): record the first transport step's numbers and decisions (I…
eywalker Nov 25, 2026
b03a944
perf(core): recipes through F, predicates and spills; design and test…
eywalker Nov 25, 2026
bea13ee
docs(dev): generic table and column names, rounded sizes in the ITL-1…
eywalker Nov 25, 2026
6539268
docs(dev): generic table and column names, rounded sizes in the ITL-1…
eywalker Nov 25, 2026
761d26b
Merge branch 'eywalker/itl-1464-run-triggers-computation-without' int…
eywalker Nov 25, 2026
ffb51d3
test(pipeline): a job's nodes read the same whatever materialize_resu…
eywalker Nov 25, 2026
4327790
Merge remote-tracking branch 'origin/eywalker/itl-1464-row-spool' int…
eywalker Nov 25, 2026
35fe257
fix(core): row spool survives forks and failed spills; whole tables a…
eywalker Nov 25, 2026
17ac88e
Merge branch 'eywalker/itl-1464-row-spool' into eywalker/itl-1464-joins
eywalker Nov 25, 2026
d57d26e
docs(dev): round the measured sizes in the views spec
eywalker Nov 25, 2026
8f81324
wip: node rows kept in the row spool (ITL-1464)
eywalker Nov 25, 2026
1b9ba90
Merge remote-tracking branch 'origin/eywalker/itl-1464-row-spool' int…
eywalker Nov 25, 2026
6a6bea4
docs(dev): keys-only joins and uniqueness certificates, with measurem…
eywalker Nov 25, 2026
9176ee7
perf(operators): joins carry source-info tokens as recipes (ITL-1464)
eywalker Nov 25, 2026
1ce5533
fix(core): unique_keys imports no protocol module (ITL-1464)
eywalker Nov 25, 2026
a04b7e4
fix(core): row spool locks no forked child inherits, and one call at …
eywalker Nov 25, 2026
764a20b
Merge branch 'eywalker/itl-1464-row-spool' into eywalker/itl-1464-joins
eywalker Nov 25, 2026
e846289
wip: sync operator node output kept on disk when large (ITL-1464)
eywalker Nov 25, 2026
b7bd6e7
fix(pipeline): never bypass a result stream's own iterator; defer a c…
eywalker Nov 25, 2026
6cf6e48
merge: transport review fixes into node rows
eywalker Nov 25, 2026
a5e72b7
docs(dev): the many-to-many worst case of an async join, measured (IT…
eywalker Nov 25, 2026
bffd906
Merge remote-tracking branch 'origin/eywalker/itl-1464-tokens-joins' …
eywalker Nov 25, 2026
ade241e
perf(operators): GroupBy and Batch carry token lists as recipes (ITL-…
eywalker Nov 25, 2026
e89544f
feat(pipeline): a job node keeps a large output on local disk, read m…
eywalker Nov 25, 2026
f3e9dc0
Merge remote-tracking branch 'origin/eywalker/itl-1464-row-spool' int…
eywalker Nov 25, 2026
393a356
docs(changelog): job nodes keep large outputs on disk (ITL-1464)
eywalker Nov 25, 2026
e94ad6e
feat(operators): record-batch channels and join kernels carry derived…
eywalker Nov 25, 2026
612f21c
docs(changelog): measured figure for node rows on disk (ITL-1464)
eywalker Nov 25, 2026
37826ed
fix(core): certify only exact classes and unreplaced instances; a joi…
eywalker Nov 25, 2026
d03873d
Merge eywalker/itl-1464-joins into eywalker/itl-1464-joins-derived
eywalker Nov 25, 2026
2da7b22
fix(streams): see every change beneath a chain that keeps nothing; sc…
eywalker Nov 25, 2026
3d1611e
Merge remote-tracking branch 'origin/eywalker/itl-1464-row-spool' int…
eywalker Nov 25, 2026
cbaeec5
Merge remote-tracking branch 'origin/eywalker/itl-1464-async-transpor…
eywalker Nov 25, 2026
c3a3068
Merge remote-tracking branch 'origin/eywalker/itl-1464-node-rows' int…
eywalker Nov 25, 2026
7062127
fix(core): the carried read is private and exact; hashes and stores r…
eywalker Nov 25, 2026
84ef349
Merge remote-tracking branch 'origin/eywalker/itl-1464-tokens' into e…
eywalker Nov 25, 2026
1af17ef
Merge remote-tracking branch 'origin/eywalker/itl-1464-tokens-joins' …
eywalker Nov 25, 2026
c0b6c4d
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins' into ey…
eywalker Nov 25, 2026
5b0e1c0
docs(dev): derived tokens in async joins, measured (ITL-1464)
eywalker Nov 25, 2026
7596150
feat(pipeline): read a job node's current run a page at a time (ITL-1…
eywalker Nov 25, 2026
3044ab5
Merge branch 'eywalker/itl-1464-tokens' into eywalker/itl-1464-tokens…
eywalker Nov 25, 2026
ae5911b
Merge branch 'eywalker/itl-1464-tokens-joins' into eywalker/itl-1464-…
eywalker Nov 25, 2026
dbff3ba
Merge remote-tracking branch 'origin/eywalker/itl-1464-views' into ey…
eywalker Nov 25, 2026
db87a5b
Merge remote-tracking branch 'origin/eywalker/itl-1464-node-rows' int…
eywalker Nov 25, 2026
5bcc712
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins-derived'…
eywalker Nov 25, 2026
8b6bc05
Merge remote-tracking branch 'origin/eywalker/itl-1464-tokens-aggrega…
eywalker Nov 25, 2026
29218d4
fix(pipeline): a kept chunk is sealed whole or not at all; a barrier …
eywalker Nov 25, 2026
9cd0b80
perf(pipeline): operator nodes run over Arrow record batches on the a…
eywalker Nov 25, 2026
6bb1bb1
docs(dev): a whole-analysis job benchmark (ITL-1464)
eywalker Nov 25, 2026
5d40153
wip: index the side that ends first (ITL-1464)
eywalker Nov 25, 2026
af69268
Merge remote-tracking branch 'origin/eywalker/itl-1464-tokens-joins' …
eywalker Nov 25, 2026
937d17b
perf(pipeline): carry token recipes between nodes on the sync path; b…
eywalker Nov 25, 2026
2071444
docs(dev): types of the whole-analysis benchmark (ITL-1464)
eywalker Nov 25, 2026
02e6f0a
wip(streams): preview(n) (ITL-1464)
eywalker Nov 25, 2026
ea7ab3b
fix(pipeline): a failed or cancelled run leaves no spill file (ITL-1464)
eywalker Nov 25, 2026
96d2f82
perf(pipeline): describe each node once per async run (ITL-1464)
eywalker Nov 25, 2026
75d0e9b
Merge remote-tracking branch 'origin/eywalker/itl-1464-node-rows' int…
eywalker Nov 25, 2026
adc6964
perf(core): the row spool writes a list's member ids once, trimmed; A…
eywalker Nov 25, 2026
19e1bfe
fix(streams): ask each stream's state once; bound a kept run() result…
eywalker Nov 25, 2026
52182ee
Merge branch 'eywalker/itl-1464-views' into eywalker/itl-1464-preview
eywalker Nov 25, 2026
e3da937
perf(operators): read an input's keys once (ITL-1464)
eywalker Nov 25, 2026
a78358f
perf(spiraldb): remember read keys as 16-byte digests (ITL-1464)
eywalker Nov 25, 2026
369076a
Merge branch 'eywalker/itl-1464-seen-keys' into eywalker/itl-1464-int…
eywalker Nov 25, 2026
b55c845
test(pipeline): batch edges hold what the row form gives (ITL-1464)
eywalker Nov 25, 2026
d330329
perf(pipeline): a barrier's record-batch input is read from local dis…
eywalker Nov 25, 2026
5bc743d
perf(operators): an async join indexes its smaller input only; two-in…
eywalker Nov 25, 2026
198f96c
Merge branch 'eywalker/itl-1464-integration' into eywalker/itl-1464-t…
eywalker Nov 25, 2026
a44cf43
feat(streams): preview(n) computes the first rows and only what they …
eywalker Nov 25, 2026
3c69020
Merge the preview and view branches into the integration state
eywalker Nov 25, 2026
2252309
docs(dev): async joins hold their smaller input's keys, measured (ITL…
eywalker Nov 25, 2026
29e5363
perf(operators): GroupBy takes its members' ids from one chunk (ITL-1…
eywalker Nov 25, 2026
049152b
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins-derived'…
eywalker Nov 25, 2026
7c547e6
Merge remote-tracking branch 'origin/eywalker/itl-1464-views' into ey…
eywalker Nov 25, 2026
1fc3ebb
feat(pipeline): function and side-effect job nodes keep their rows in…
eywalker Nov 25, 2026
7f2635f
fix(operators): a join's held rows cost what is held, whatever was he…
eywalker Nov 25, 2026
60794ed
Merge eywalker/itl-1464-joins (the #565 mask fix, which this branch a…
eywalker Nov 25, 2026
f6d0486
docs(dev): what async joins change for users, and the bytes of a held…
eywalker Nov 25, 2026
982f1dc
docs(dev): correct the split of a held key row's bytes (ITL-1464)
eywalker Nov 25, 2026
5a86f45
perf(streams): a view's display reads only the rows it shows; a job n…
eywalker Nov 25, 2026
829f718
Merge remote-tracking branch 'origin/eywalker/itl-1464-integration' i…
eywalker Nov 25, 2026
ccc8e51
fix(operators): a join kernel reads derived token lists as text (ITL-…
eywalker Nov 25, 2026
ae9fa53
perf(pipeline): a sync source node reads a batched source off process…
eywalker Nov 25, 2026
d02851a
Merge remote-tracking branch 'origin/eywalker/itl-1464-node-rows' int…
eywalker Nov 25, 2026
937bbfe
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins-derived'…
eywalker Nov 25, 2026
faa4d88
test(operators): random graphs show no certificate changes a result (…
eywalker Nov 25, 2026
c6f0ccb
fix(operators): one memory limit for mixed token forms, no recipe in …
eywalker Nov 25, 2026
df4314e
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins-derived'…
eywalker Nov 25, 2026
1954f6a
perf(operators): grouping millions of rows; measured (ITL-1464)
eywalker Nov 25, 2026
baf84ec
Revert "feat(pipeline): function and side-effect job nodes keep their…
eywalker Nov 25, 2026
420aec8
Merge remote-tracking branch 'origin/eywalker/itl-1464-integration' i…
eywalker Nov 25, 2026
3dc4144
Merge branch 'eywalker/itl-1464-integration' into eywalker/itl-1464-t…
eywalker Nov 25, 2026
82c7386
docs(hashing): list the streaming joins' canonical input order (ITL-1…
eywalker Nov 25, 2026
cf93263
docs(dev): job measurements of grouping millions of rows (ITL-1464)
eywalker Nov 25, 2026
a23c8ff
docs(dev): the tracks together, measured (ITL-1464)
eywalker Nov 25, 2026
31cb626
fix(operators): a join puts rows of both token forms together whateve…
eywalker Nov 25, 2026
b6e8610
Merge remote-tracking branch 'origin/eywalker/itl-1464-joins-derived'…
eywalker Nov 25, 2026
2dda2d8
fix(streams): a preview holds the streams it remembers, so a freed on…
eywalker Nov 25, 2026
17e1170
perf(operators): GroupBy sorts low-cardinality text by rank (ITL-1464)
eywalker Nov 25, 2026
dcc2b96
Merge remote-tracking branch 'origin/eywalker/itl-1464-integration' i…
eywalker Nov 25, 2026
a5b50f9
Merge remote-tracking branch 'origin/eywalker/itl-1464-preview' into …
eywalker Nov 25, 2026
07f0398
Merge commit 'dcc2b96f477c0d4f2619cff502a209e04de1d97f' into eywalker…
eywalker Nov 25, 2026
508c7fe
docs(dev): final numbers of the tracks together (ITL-1464)
eywalker Nov 25, 2026
11e4775
docs(dev): a job shaped like a real analysis, measured (ITL-1464)
eywalker Nov 25, 2026
ca15ac4
Merge remote-tracking branch 'origin/main' into eywalker/itl-1464-run…
eywalker Nov 26, 2026
bb7bab5
docs(specs): answer the review of the streaming design and its measur…
eywalker Nov 26, 2026
fdf70e9
fix(streams): a preview never reads a derived source's origin whole, …
eywalker Nov 26, 2026
d9d30ce
Merge branch 'eywalker/itl-1464-preview' (fdf70e94) into eywalker/itl…
eywalker Nov 26, 2026
78e581c
docs(specs): second review round of the streaming design (ITL-1464)
eywalker Nov 26, 2026
fdc7c8d
Merge remote-tracking branch 'origin/eywalker/itl-1464-run-triggers-c…
eywalker Nov 26, 2026
342d8bb
fix(streams): a derived source previews its origin batch by batch (IT…
eywalker Nov 26, 2026
c60a33c
Merge branch 'eywalker/itl-1464-preview' (342d8bb0) into eywalker/itl…
eywalker Nov 26, 2026
4ed79de
Merge remote-tracking branch 'origin/main' into eywalker/itl-1464-run…
eywalker Nov 26, 2026
d744e8d
docs(specs): third review round of the streaming design (ITL-1464)
eywalker Nov 26, 2026
1fb05cc
Merge remote-tracking branch 'origin/eywalker/itl-1464-run-triggers-c…
eywalker Nov 26, 2026
5664f1d
docs(specs): fourth review round of the streaming design (ITL-1464)
eywalker Nov 26, 2026
ed5cbce
Merge remote-tracking branch 'origin/eywalker/itl-1464-run-triggers-c…
eywalker Nov 26, 2026
27a78a1
docs(specs): per-key counts in the join's cost and the stated bound (…
eywalker Nov 26, 2026
27f38c2
Merge remote-tracking branch 'origin/eywalker/itl-1464-run-triggers-c…
eywalker Nov 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions changelog.d/ITL-1464.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
### Added

- `stream.preview(n)`: the first `n` rows of a stream that is not computed, computing only what
they need (ITL-1464). Functions are called on as few rows as that takes; nothing is kept,
stored or delivered. A step that needs its whole input (a join, `group_by`, ...) is refused
unless `compute_all=True`.

### Changed

- A `SpiralDBTableSource` read whose table holds no source-info column and no content hash
(`as_table()`, `run()`, `as_polars_df()` with the default columns) no longer builds the
source-info tokens of every row and column only to drop them. The rows and the table are
the same; on a table of 2.2 million rows and 13 columns the read's peak memory falls from
10.8 GiB to 2.0 GiB (ITL-1464).
- An async job run keeps the rows a node passes on as Arrow tables of at most 8,192 rows,
not as one pair of objects per row: in an operator job node's output, in the input of an
operator that reads all of its input first (`PolarsFilter`, `GroupBy`, `MergeJoin`,
`Rejoin`, `Batch` without a size), and no longer at all in the orchestrator for a job
(which never read them). Results are unchanged. An async job of `drop_nulls`, `group_by`,
`map_data` and a function pod over 200,000 rows peaks at 4.8 GiB instead of 19.7 GiB
(ITL-1464).
- An operator job node keeps a large output of its run (more than 64 MiB) in a private
temporary file, read back memory-mapped, instead of in process memory. So does, on the
async path, the input of an operator that reads all of its input first. The files are
removed when the run ends, fails or is cancelled. Every read of the
node gives the same rows; a table read from it stays valid after the node and the job are
gone. An async job of one row-by-row operator over 1 million rows holds 0.9 GiB of its own
memory instead of 4.4 GiB (ITL-1464).
- Reading a source and applying an operator that selects, renames, filters or tags rows
no longer builds the source-info text of every row and column. The text is built when
it is shown, stored or handed to a function, a part of the rows at a time, so these
steps take a few times the memory of their data instead of tens of times (ITL-1464).
Values, hashes and stored tables are unchanged.
- `run()` of a `SpiralDBTableSource`, and of column selections, renames, `add_tags`,
`drop_nulls` and `filter` over one, reads the table in batches and no longer holds a result
of more than 50,000 rows or 64 MiB of values (ITL-1464). The view then has the row count and the first and the
last 1,000 rows; it is displayed as before, and its `table`, `as_table()`,
`as_polars_df()`, `sort_by_tags()` and a longer `head` or `tail` raise `BoundedViewError`,
which names the stream's own methods. `stream.as_table()` and iteration are unchanged; after
such a run `as_table()` reads the source again. Smaller results, and every other stream,
are as before.
- Reading a SpiralDB table remembers each row's key as 16 bytes instead of its text, to
find a key read twice: about 130 MB for 8 million rows instead of 2 GB (ITL-1464).
59 changes: 54 additions & 5 deletions docs/concepts/streams.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,10 @@ print(months.head(3).header())
### Computing a stream outside a job: `run()`

Every stream, source and node has `run()`, with no arguments: it is the one way to compute
any of them outside a job (developer, November 13, 2026). It does exactly the work
`as_table()` does, through the same cache, and returns a `StreamView` of every row with the
default columns. A stream already computed is not computed a second time; one whose input
any of them outside a job (developer, November 13, 2026). It computes every row, with every
effect, in the order of `as_table()`, and returns a `StreamView` with the default columns. It
promises nothing about how the rows are produced or what is held meanwhile (developer,
November 24, 2026). A stream already computed is not computed a second time; one whose input
changed is recomputed. In a notebook, `stream.run()` at the end of a cell computes and displays.

The view's own methods choose what is shown. Each returns a new view and never reads or
Expand All @@ -209,21 +210,69 @@ view does not hold, so it keeps them in the order it has them. The display of a
such as the one `run()` returns, shows its first and last five rows when it has more than
ten, and its header gives the count.

A view holds every row of the stream, with one exception, the bounded view. A
`SpiralDBTableSource` holds no rows, and `run()` reads it in batches; so are read the
operators that choose or rename columns, add tags or drop rows (`select_*`, `drop_*`,
`map_*`, `add_tags`, `drop_nulls`, `filter`) and the chains of them over such a source. A
result of at most 50,000 rows and 64 MiB of values (the values themselves, whatever their
layout in memory), or of at most 2,000 rows, is held, as everywhere else. A larger one is not: its view has
the row count, the columns, and the first and the last 1,000 rows. It is displayed as any
view, and `head(n)` and `tail(n)` up to 1,000 rows give what any view gives. What needs the
other rows (`table`, `as_table()`, `as_polars_df()`, `sort_by_tags()`, a longer `head` or
`tail`) raises `BoundedViewError`: a part is never given as the whole. Ask the stream itself,
`stream.as_table()`, which reads the source again and applies the operators again (no function
of yours runs a second time). `stream.head(n)` after such a run shows its first rows. Whether
a view is bounded depends only on the kind of stream and on its rows, so equal data
always gives the same kind of view. A `polars_filter`, `pick`, `index`, `tag_by`, join,
`group_by` or `batch`, a function pod, and everything after one, computes its whole result
and holds it, also over a `SpiralDBTableSource`.

A view holds the default column groups only. For system tags, source info, the data context
or content hashes, ask the stream after `run()`. A function pod's or operator's output stream,
a job node (a job's side-effect node included), an in-memory source and a `CachedSource` keep
the rows `run()` gave: their `as_table(columns=...)` and `head(columns=...)` read those rows,
compute nothing and deliver no side effect. Other streams do their `as_table()` work again: a
side-effect stream outside a job delivers its side effects again (its `head()` shows no rows),
a polling source polls again and a `SpiralDBTableSource` reads its whole table again. A view never asks its stream for more columns, because for those
a polling source polls again and a `SpiralDBTableSource` reads its whole table again (so does
an operator's stream whose `run()` gave a bounded view). A view never asks its stream for more columns, because for those
streams asking again is not a read.

### The first rows of a stream not computed yet: `preview(n)`

`head()` never computes, so it has nothing to show of a derived stream nobody ran.
`preview(n)` computes the first `n` rows of `as_table()`, and only what they need:

```python
first = months.preview(2)
print(first.header())
# FunctionPodStream[months] — preview: first 2 rows (run() computes every row)
print(first.as_table().column("age_months").to_pylist())
# [108, 120]
```

A source reads no more than is needed, an operator takes batches until enough rows have
passed, and **your functions are called**, on one row after another until `n` rows have come
out. Nothing is kept on a stream, nothing is stored (a pod with stored results reads them and
adds none), and no hook fires; calling `preview` again computes again. Results a stream
already holds are used. A view of fewer rows than asked for says it shows all of them.

A join, `group_by`, `batch`, `polars_filter`, `tag_by`, `pick`, `index` or an operator of your
own needs every row of its input, so `preview` refuses it (`PreviewRefusedError`, naming the
step). `preview(n, compute_all=True)` computes that step and everything beneath it in full,
functions included, and keeps none of it. A side-effect pod, a function that takes the
invocation context, a `CachedSource`, a `PollingSource` and a node of a pipeline or job are
refused always: a preview never acts. A `semi_join` whose inputs share no tag keeps every row
of its left input and never reads its right one, so `preview` reads only the left input, as
the full read does. A `DerivedSource` over a source shows its origin's first rows through
the origin's own `preview` (refused for a `CachedSource` or `PollingSource` origin); over a
job node it reads the stored rows, only with `compute_all=True`. It keeps none of them.

What `run()` does on each kind of object:

| Object | `run()` |
|---|---|
| An in-memory source (`DictSource`, `ArrowTableSource`, ...), a Delta or SQL table source | nothing to compute: a view of the rows it holds |
| A `SpiralDBTableSource` | reads the whole table into memory (`head()` is the bounded read); every call reads again |
| A `SpiralDBTableSource` | reads the whole table in batches (`head()` is the bounded read); every call reads again; a bounded view above 50,000 rows or 64 MiB |
| A `PollingSource` (provisional, see [Provisional sources](sources.md#provisional-sources)) | polls, as `as_table()` does |
| A `CachedSource` | reads its cache and writes the wrapped source's new rows to it |
| A function pod's or operator's output stream | computes what is not computed yet |
Expand Down
98 changes: 98 additions & 0 deletions docs/dev/specs/itl-1464-integration.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
# The ITL-1464 tracks together: batch edges, and what a whole analysis costs

## What connects the tracks

- **Edges.** An async job's edge carries `(Tag, Data)` pairs or record batches of a node's
rows (`core/job_edges.py`, over the channels of `orcapod.channels`). A source node whose
table is provably its rows, and an operator node, send batches of at most 8,192 rows; a
node that knows only pairs (a function, a side effect) is given pairs, made as it reads.
- **Operator nodes** run `async_execute_batches` over the edges, when the operator and every
operator above it are the library's own classes and everything is in the default data
context. Otherwise they run the row form, unchanged. Each input channel's stream is the
node's own input, so a uniqueness certificate is the node's. `Filter` is row by row.
- **Token recipes** travel between nodes on both paths; text is made where a row, a store or
a hash needs it. A join over an aggregation's output runs on its whole inputs: a kernel's
files cannot share the ids that derived token lists share.
- **Kept rows** (a node's output, a barrier's input, a sync source's table) go through a
`RowSpool`; rows with derived token lists stay in memory, where they share their ids.
- One async run derives each node's zero-row table and certificate once.

## Measured

`docs/dev/specs/itl-1464/chain.py`: 8.1 million events and 2.2 million series rows at 100%,
read by the real source over the fake client. Peak physical footprint / peak resident memory
in GB, and seconds. Memory beyond the footprint is memory-mapped pages of local files.

Async:

| Step | 25% | 50% | 100% |
|---|---|---|---|
| events semi-joined with the kept items | 0.4 / 1.1, 15 s | 0.5 / 1.8, 32 s | 0.7 / 3.2, 66 s |
| then filtered by time | 0.5 / 1.6, 15 s | 0.7 / 2.9, 32 s | 0.8 / 5.3, 68 s |
| then joined with a lookup table | 0.6 / 2.8, 17 s | 0.8 / 5.2, 34 s | 1.0 / 10.0, 85 s |
| filtered events grouped by item | 2.1 / 3.5, 27 s | 3.9 / 6.8, 55 s | 4.6 / 9.4, 115 s |
| series filtered, grouped, one function | 1.4 / 2.1, 8 s | 2.6 / 3.7, 15 s | 4.5 / 8.2, 33 s |
| the whole job | 3.0 / 4.4, 38 s | 5.3 / 8.2, 78 s | 7.4 / 20.0, 164 s |

The 100% column includes the aggregation step that sorts text by rank and spools token
lists (#573); the 25% and 50% columns were measured before it. It lowers the footprint and
raises resident memory (mapped pages).

Sync:

| Step | 25% | 50% | 100% |
|---|---|---|---|
| semi-join | 1.8 / 2.6, 14 s | 3.2 / 4.6, 32 s | 6.0 / 8.9, 67 s |
| filter | 1.8 / 3.0, 15 s | 3.2 / 5.5, 33 s | 6.0 / 10.6, 69 s |
| lookup join | 2.3 / 5.0, 15 s | 4.2 / 9.3, 32 s | 7.5 / 18.6, 72 s |
| group by | 2.5 / 4.2, 25 s | 4.4 / 7.8, 55 s | 6.0 / 12.0, 115 s |
| series and function | 1.9 / 2.7, 7 s | 3.9 / 5.0, 14 s | 5.8 / 10.8, 30 s |
| the whole job | 4.8 / 7.1, 37 s | 8.7 / 13.3, 71 s | above 24 GB, killed |

`main` at 25%: the semi-join takes 10.7 / 10.9, 12 s on sync; the semi-join on async, and
the lookup join and the whole job on both paths, pass 24 GB and are killed.

Row-by-row steps are slower on sync than on `main` (12 s to 14 s here): the source's rows go
through a local file.

## The shape of a real analysis: longer ids, a function per group

`chain.py setup --items 140 --id-length 72` (98 groups kept), async, the whole job. Peak
physical footprint in GiB:

| Job | 25% | 50% | 100% |
|---|---|---|---|
| with a cheap function per group | 2.3 | 4.2 | not completed: killed above 24 GiB of resident memory, at a footprint of at least 6.5 |
| with one outer product of a group's event times and all peak times in the function | 13.6 | not run | not run |
| the same, `PodConfig(max_concurrency=4)` | 5.4 | | |
| the same, `PodConfig(max_concurrency=1)` | 3.5 | | |

Function calls have no limit by default (`default_max_concurrency` is `None`): 22 ran at once
here, the size of the event loop's thread pool. Each held 0.3 GiB for each of two arrays at
25%; such a function's arrays grow with events times peaks, so 16 times at 100%. No library
change bounds that: a limit on calls in flight, or a function that does not build the product.

At 100% the mapped pages (14 of 21 GiB resident when the run was killed) are what a guard on
resident memory counts.

## What is bounded, and what is not

Bounded on async: sources, row-by-row operators, joins with a small or certified side. They
grow by the digests of the keys read (16 bytes a row), and by file pages the system can drop.
Whether a container that counts mapped pages drops them in time is not tested.

Not bounded, in the order of their cost in the whole job at 100%:

1. Writing a function node's stored rows (the peak of the whole job when profiled, before #573): a row holds the source-info text
of its inputs' token lists, millions of tokens in one row, and the Delta writer holds
copies. The stored layout decides the text.
2. `GroupBy` over its whole input (4.6 GB for 5.7 million member rows): the sort of its members
and the copies of what it takes. The members' data it keeps is 64 MB; the rest is ids.
3. A function's input row that is one large group: its token text, then Python lists.
4. On sync, each operator's own whole result while it is moved to local disk.

## Gates

The ITL-1347 differential against `main` (both fixtures, all modes, one and default Polars
threads): sync exact and async as sets, all equal. At the final head: equal, and 24,560 tests pass. Every operator node's rows, system tags
and tokens in the job above, at 0.5%, have `main`'s digests on both paths.
Loading
Loading