Skip to content

perf(pipeline): keep async rows as Arrow chunks, not object pairs (ITL-1464) - #562

Closed
eywalker wants to merge 22 commits into
mainfrom
eywalker/itl-1464-async-transport
Closed

eywalker wants to merge 22 commits into
mainfrom
eywalker/itl-1464-async-transport

Conversation

@eywalker

@eywalker eywalker commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Draft, for ITL-1464: the first transport step. Stacked on #558 (its commits are included here until it merges).

What this does

On the async path every row was kept as a (Tag, Data) pair of objects (18 to 110 KiB per row against a few KiB as Arrow data), in four places. Each now keeps Arrow tables of at most 8,192 rows, or nothing:

Place Before Now
The orchestrator's result collectors every row of every node, for a result job.run() discards a job asks for none (materialize_results=False to the async orchestrator)
The orchestrator's drain of terminal nodes collect() into a list nobody reads rows are read and let go
OperatorNode.async_execute, the node's kept output a list of every pair, then one table RowChunks
Barrier operators' gathered input (PolarsFilter, GroupBy, TagBy, MergeJoin, Rejoin, Batch without a size) channel.collect() collect_row_chunks
A barrier's result while it is sent ArrowTableStream.iter_data keeps every pair rows_once (iter_data_unkept)

RowChunks.row_table() equals _rows_to_table(rows) (columns, types, field flags, values; only the arrays' chunking differs), so every stream, hash and stored row is the one built before. No hash, identity, stored layout or golden value moves; no public promise changes (a job's materialize_results never affected what a job returns or keeps).

Measured (async job, synthetic 13-column table, peak resident memory less the import, per row)

Job Before After
map_data 54 KiB 7.7 KiB
drop_nulls 90 KiB 8.6 KiB
polars_filter 109 KiB 12.5 KiB
join (large with small) 68 KiB 21 KiB
group_by 57 KiB 15 KiB
drop_nulls, group_by, map_data, function pod 102 KiB (19.7 GiB at 200,000 rows) 24 KiB (4.8 GiB)

Before: 20,000 rows (the chain also at 200,000); after: 200,000 rows. What remains is the tokenized Arrow table each node keeps (about 4.5 KiB per row per kept copy) and Join's row-form buffers: the next steps.

The chunk, as a contract for the next steps

A chunk is at most 8,192 rows (ROW_CHUNK_ROWS) in the form a job's edge carries: the user tags, the system-tag columns, the data columns (a data-tag once, among the tags) and one _source_<column> token column per data column, with each row's data context beside it. It is the record batch an ITL-1347 channel carries before the last step of the row-built form (the source-info field flags, decided over all rows). Next in this line of work: operator nodes run async_execute_batches over record-batch channels (the streaming join kernels for joins), and a node keeps a reference to spilled or stored rows instead of the table.

Tests

tests/test_core/operators/test_row_chunks.py: the row table and both streams equal the row-list builders' at chunk sizes 1, 3, 4, 11 and 8,192, with data-tags and tag-only tags, two tags and several data columns, a row with a missing token; at most one chunk of pairs is held; a channel is collected in order; a result read once is not kept; async jobs over several chunks give the sync rows (map_data, group_by, drop_nulls then batch), with equal content hashes; a job asks the async orchestrator to keep no rows.

Run locally: tests/test_pipeline, tests/test_core/operators, tests/test_core/streams, tests/test_core/function_pod (18,857 passed, one process), ruff check, ruff format --check, basedpyright (0 errors), golden --check (no value moved).

Review findings and their tests

Finding (independent review of 614e5f7) Fix Test
A barrier's result was read around its own iterator when the stream was an ArrowTableStream subclass or had iter_data set on the instance rows_once takes the unkept path only for exactly ArrowTableStream with its own iterator test_a_result_streams_own_iterator_is_never_bypassed
A full chunk that cannot make one table raised while a barrier was still collecting: the other input's reader was left behind, and an error was raised where main returns no rows for an empty other input RowChunks.add raises for want of memory only: the rows wait as they came and the error is raised by row_table(), as the row list raised it test_rows_that_cannot_make_one_table_raise_when_it_is_read_not_when_added, test_a_barrier_with_an_empty_input_never_reads_the_other_as_a_table
Round 2: a chunk that failed part way was built again and its rows given twice a chunk is published whole; a failure is permanent and every read raises it; a want of memory ends the run at once test_a_chunk_that_failed_once_is_never_built_or_given_again, test_a_job_never_succeeds_with_rows_twice_after_a_failed_allocation
Round 2: the first row's keys were read as it arrived, and the error left a sibling reader a row is read only when its chunk is built; the barriers cancel and await every reader on any error test_a_row_is_not_read_when_it_is_added, test_a_barrier_leaves_no_reader_behind
Round 2: pairs accumulated after a failed seal no row is kept after a failure test_rows_after_a_chunk_that_cannot_be_built_are_not_kept
Behaviour note (decision T-1, approved by the coordinator for the developer's review): a job always passes materialize_results=False to the async orchestrator intended test_an_async_job_run_asks_the_orchestrator_to_keep_no_rows, test_a_jobs_nodes_read_the_same_whatever_materialize_results_says

Mentions ITL-1464.

🤖 Generated with Claude Code

eywalker and others added 4 commits November 25, 2026 00:56
…one (ITL-1464)

A SpiralDBTableSource read whose table holds no source-info column and no
content hash built one token per row and data column, then dropped them. On
2.2 million rows of 13 columns that was 9.3 GiB of Arrow memory for a 282 MiB
table. The read now builds them only when its result shows or hashes them.

Adds the memory diagnosis (docs/dev/specs/itl-1464-memory-diagnosis.md) and
the scripts it was measured with.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…L-1464)

An async job kept every row three times as (Tag, Data) pairs: in the
orchestrator's result collectors (never read by a job), in each operator job
node's output list, and in each barrier operator's gathered input, plus the
pairs an ArrowTableStream caches while a barrier sends its result. Rows are
now kept as Arrow tables of at most 8,192 rows (RowChunks), which build
exactly the table the row list built.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Nov 25, 2026

Copy link
Copy Markdown

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

eywalker and others added 6 commits November 25, 2026 01:37
…TL-1464)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…464 material

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…464 material

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…lts says (ITL-1464)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…hunk's error to the read (ITL-1464)

Review of PR 562: rows_once took the unkept path for any ArrowTableStream
subclass or shadowed iter_data, and a full chunk that cannot make one table
raised while a barrier was still collecting, leaving the other input's reader
behind and raising where main returned no rows for an empty other input.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/orcapod/core/nodes/operator_node.py 95.84% <100.00%> (ø)
src/orcapod/core/operators/base.py 93.27% <100.00%> (-0.06%) ⬇️
src/orcapod/core/operators/batch.py 100.00% <100.00%> (ø)
src/orcapod/core/operators/static_output_pod.py 95.88% <100.00%> (+0.51%) ⬆️
src/orcapod/core/sources/spiraldb_table_source.py 98.10% <100.00%> (+0.29%) ⬆️
src/orcapod/core/sources/stream_builder.py 98.87% <100.00%> (+<0.01%) ⬆️
src/orcapod/core/streams/arrow_table_stream.py 97.05% <100.00%> (+0.12%) ⬆️
src/orcapod/pipeline/async_orchestrator.py 97.66% <100.00%> (-0.65%) ⬇️
src/orcapod/pipeline/job.py 96.75% <ø> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

eywalker and others added 12 commits November 25, 2026 02:29
…leaves no reader behind (ITL-1464)

Review of PR 562, round 2: a chunk that failed part way was built again and its
rows given twice; the first row's keys were read as it arrived; after a failed
chunk the pairs accumulated; a failing barrier left its sibling's reader alive.
A failure is now permanent, a want of memory ends the run at once, a row is read
only when its chunk is built, and the barriers end every reader on any error.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ements (ITL-1464)

The design states that the cache root must be on disk, bounds the pairs of
one join match, qualifies the SQLite primary-key trust, counts small results
kept in memory and narrows the preview's side-effect promise. The measurement
steps each use their own emptied result location, and setup runs under the
memory guard. One test runs an operator over the source in a job, sync and
async, in two tag orders.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
The design names how a database-backed node read keeps the emitted order,
runs a PolarsFilter per batch only for a predicate known to be row-wise,
corrects the 1:1 join bound for inputs that share no key and fixes the
arrival order of the bound's tests. The job test over the source covers the
named columns as data, data-tags and tags, two table layouts and row
multiplicity on the async path; the measurement scripts get docstrings.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…omputation-without' into eywalker/itl-1464-async-transport
A node's reference names the stored row the run emitted (base entry id and
recomputation index), the stated bound excludes steps that need their whole
input, and async results are compared with sync row for row with
multiplicity.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…omputation-without' into eywalker/itl-1464-async-transport
The cache is read only from closed segments and waiting rows, a preview
continues one open read, the join index counts its per-key counts, and a
whole-input step counts its output and conversion buffers.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…omputation-without' into eywalker/itl-1464-async-transport
…ITL-1464)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
…omputation-without' into eywalker/itl-1464-async-transport
@eywalker

eywalker commented Dec 2, 2026

Copy link
Copy Markdown
Contributor Author

Closing as part of the ITL-1464 draft group. The async-route work continues as ITL-1347 stage 5 (ITL-1845). The SpiralDB read work landed in #687 and #679, and continues in #683.

Posted by a Claude Code agent on behalf of @eywalker.

@eywalker eywalker closed this Dec 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant