Skip to content

perf(operators): async joins hold keys only, with uniqueness certificates (ITL-1464) - #565

Closed
eywalker wants to merge 14 commits into
mainfrom
eywalker/itl-1464-joins
Closed

eywalker wants to merge 14 commits into
mainfrom
eywalker/itl-1464-joins

Conversation

@eywalker

@eywalker eywalker commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

Draft, a step of ITL-1464 (the issue stays open). Contains #559 (the row spool); review that one first.

What this does

  • Async joins hold keys, not rows. Join, MergeJoin and SemiJoin over record-batch channels (async_execute_batches) run on the ITL-1362 kernels: join keys and row numbers in memory, the rows in a row spool, the output in pieces of at most 8,192 rows.
  • Uniqueness certificates. StreamProtocol.unique_keys: the tag sets no two rows agree on, derived when asked. A row is let go once it has matched if and only if the other side is unique on the join keys. It is in no hash, identity, config, stored row or equality. An unknown class or a subclass certifies nothing.

No job node calls this form yet; the transport work wires it. The sync path is unchanged. No hash, identity, stored layout or golden value moves (golden --check clean). Rejoin stays a barrier here.

Design, cases, bounds and the certificate table: docs/dev/specs/itl-1464-joins.md.

Measured (the operator alone, synthetic rows; peak RSS, 143 MiB of it imports)

Case Rows Before (barrier) After
large input against a lookup of 300 1,000,000 1,793 MiB, 2.3 s 259 MiB, 2.4 s
the same 8,000,000 not run 257 MiB, 19.9 s
1:1, one input entirely first 1,000,000 2,574 MiB, 4.4 s 741 MiB, 5.1 s
the same 8,000,000 not run 2,301 MiB, 60.0 s
1:1, in step 8,000,000 not run 341 MiB, 39.3 s
many to many, 5 output rows per row 1,000,000 4,835 MiB, 2.4 s 445 MiB, 3.2 s
the same 8,000,000 not run 453 MiB, 26.0 s
semi-join 8,000,000 not run 252 MiB, 19.6 s

The "one input first" cases grow with that input's keys, as designed. The many-to-many case has its small side ended first; with both inputs open and no certificate the bound is both sides' keys.

Tests

  • test_keys_only_joins.py: the sync rows as a set for 1:1, lookup on either side, many to many, null keys, float keys, no shared tag, three inputs, differing tag orders and layouts, every spool in memory and on disk; what is held; diamonds through bounded channels, failure, cancellation, backpressure, subclasses. Swapping the rule's two sides fails 44 of them.
  • test_unique_keys.py: every step's certificate, and that it holds on the rows; what certifies nothing.

No changelog fragment: nothing user-visible until the nodes use it, and changelog.d/ITL-1464.md belongs to #558.

Mentions ITL-1464.

🤖 Generated with Claude Code

Review round 1: finding -> test

Finding Test
A customized source or operator instance kept its class's certificate, and the async join lost a row test_a_customized_input_that_repeats_a_key_loses_no_row; test_a_source_with_a_replaced_reader_certifies_nothing, test_an_operator_with_a_replaced_body_certifies_nothing, test_a_stream_or_node_with_a_replaced_reader_certifies_nothing, test_a_function_pod_with_a_replaced_call_certifies_nothing
The same guard for the join itself test_a_customized_join_keeps_its_own_computation
The held-row mask grew with every row that ever passed test_what_an_in_step_join_keeps_does_not_grow_with_the_rows_that_passed, test_rows_held_for_long_among_rows_that_pass_are_matched_at_the_end
An oversized producer batch is taken whole; spool ownership wording stated in the spec and the docstring

Many to many with both inputs open and no certificate, measured since: 8,000,000 rows, 40,000,000 out, 2,629 MiB, 57.3 s (barrier at 1,000,000: 6,068 MiB).

Review round 2: finding -> test

Finding Test
One old unmatched row pinned the row mask for every later row test_one_old_row_does_not_pin_what_later_rows_cost
A structural stream of the previous protocol is refused (also round 3) accepted, see below

This pull request is correct on its own. #567, after it, replaces how the larger side is held and adds the rest; its numbers supersede those above.

Protocol change. StreamProtocol gains a required member, unique_keys. Orcapod's protocols are internal: they are extended with required members, with no fallback for other implementations (developer, November 22, 2026). Every stream class of the library and everything built on StreamBase has it. A hand-written structural stream must add it; the empty set (frozenset()) is valid and certifies nothing.

eywalker and others added 11 commits November 25, 2026 01:20
…isk (ITL-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ws, with bounded output batches (ITL-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…geJoin and SemiJoin streaming on record-batch channels (ITL-1464)

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

A forked child neither waits for a lock of its parent's threads nor touches its parent's
files; a failed spill leaves the spool as it was; an unlocked or partly removed directory is
swept. table() and slice() give rows through their mappings and outlive the spool.

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

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

Co-Authored-By: Claude Opus 5.5 <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

…L-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…n's row mask is bounded by the rows held (ITL-1464)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 25, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.46772% with 29 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/orcapod/core/row_spool.py 96.93% 9 Missing ⚠️
src/orcapod/core/operators/merge_join.py 58.82% 7 Missing ⚠️
src/orcapod/core/operators/streaming_joins.py 98.48% 4 Missing ⚠️
src/orcapod/side_effects.py 76.92% 3 Missing ⚠️
src/orcapod/core/cached_function_pod.py 80.00% 1 Missing ⚠️
src/orcapod/core/exact_class.py 94.11% 1 Missing ⚠️
src/orcapod/core/nodes/function_node.py 85.71% 1 Missing ⚠️
src/orcapod/core/operators/index.py 66.66% 1 Missing ⚠️
src/orcapod/core/operators/pick.py 66.66% 1 Missing ⚠️
src/orcapod/core/operators/static_output_pod.py 88.88% 1 Missing ⚠️
Files with missing lines Coverage Δ
src/orcapod/core/function_pod.py 96.63% <100.00%> (+0.03%) ⬆️
src/orcapod/core/nodes/operator_node.py 95.89% <100.00%> (+0.04%) ⬆️
src/orcapod/core/nodes/source_node.py 95.93% <100.00%> (+0.05%) ⬆️
src/orcapod/core/operators/add_tags.py 100.00% <100.00%> (ø)
src/orcapod/core/operators/column_selection.py 99.37% <100.00%> (+0.02%) ⬆️
src/orcapod/core/operators/drop_nulls.py 99.03% <100.00%> (+0.02%) ⬆️
src/orcapod/core/operators/filter.py 100.00% <100.00%> (ø)
src/orcapod/core/operators/filters.py 87.05% <100.00%> (+0.47%) ⬆️
src/orcapod/core/operators/group_by.py 100.00% <100.00%> (ø)
src/orcapod/core/operators/join.py 98.61% <100.00%> (+0.04%) ⬆️
... and 23 more

... and 3 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 added a commit that referenced this pull request Nov 25, 2026
…put Rejoin streams; channels give text to public reads (ITL-1464)

Review of #565 and #567: a held row costs what is held, whatever was held before it; a
channel's public read gives text and reads a stream through its own reader; batches may mix
text and derived tokens however they arrive.

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

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@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