Skip to content

D-SRAM-2 spike: semijoin reduction before preparation - #1632

Merged
AdaWorldAPI merged 3 commits into
mainfrom
ccr-d3ce1263-ied9yh
Oct 20, 2026
Merged

AdaWorldAPI merged 3 commits into
mainfrom
ccr-d3ce1263-ied9yh

Conversation

@AdaWorldAPI

Copy link
Copy Markdown
Owner

Follow-up to #1631. This PR carries the semijoin commits, which were pushed after #1631 had already been merged. It is still the D-SRAM-2 lab research spike, not authorization.

What changes

  • crepe-plan-probe: when a star side is restricted by a constant, every side keeps only the rows whose center value appears in all restricted sides. The lookup is a sorted Vec<u32> with binary search; no HashMap/HashSet. A center outside that set cannot reach the joint mask, so answers and bag multiplicities do not change.
    • Switch: Options::semijoin, on in Options::ALL.
    • Entry point: native::prepare_semijoin. prepare is unchanged.
  • examples/measure.rs: a no-semijoin configuration measures the reduction separately.
  • Plan and board: plan §2b and the follow-ups are updated, and the board entry records the reduction.

Evidence

Release build, n = 50,000 Parent rows:

rows laid out prepare
with semijoin 36 0.28 ms
without 56,286 3.47 ms
  • With the semijoin, 36 rows are laid out at every size.
  • Mask and terminal times are unchanged.
  • Answers match the oracles at 100, 1k, 10k and 50k rows.

Tests N (4), with exact counts of prepared rows:

  • set, bag, count and exists give the same answers (11 vs 417 rows);
  • with no restricted side, nothing changes;
  • an empty restricted side prepares 0 rows;
  • two restricted sides are intersected (5 vs 7 rows; bag multiplicity 2 is kept).

Disable runs, each red:

  • no reduction;
  • first restricted side only;
  • filtering by the wrong column.

All 20 tests are green; clippy -D warnings and fmt are clean.

Open

  • Preparation still scans every row once, so it stays O(n); only the layout became O(k). Removing the scan needs a key-column index on the stored relations.
  • A reduced table refuses re-sealing a side with rows for other centers (OutsideDomain).

Generated by Claude Code

When a star has a side restricted by a constant, every side is laid out
only for the centers all restricted sides have (sorted Vec, binary
search). Centers outside that set cannot reach the joint mask, so answers
and bag multiplicities are unchanged. Options::semijoin, on in ALL.

Tests N: same answers set/bag/count/exists with exact prepared-row
counts, no change without a restricted side, empty restricted side,
intersection of two restricted sides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a08237ab-9a04-4130-9367-e58d6f71add1
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Warning

Billing warning: we have not been able to collect payment for this subscription for more than 72 hours. Please update the payment method or pay any pending invoices in Billing to avoid service interruption.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

examples/row_filter.rs compares the scalar binary-search filter with
ndarray's strided compare over the row bytes and its contiguous compare
over a u32 column (all three agree; word-boundary sizes checked). Over
the row-major store the strided pass is slower at every needle count, so
prepare keeps the scalar test; over a contiguous column it is 5.8 us per
needle at 50,000 rows and wins up to 64 needles. ndarray is a
dev-dependency at the coordinate mask-risc uses. Plan §2c and board.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VncKoyG6JkpsoqhqTGTv3f
@AdaWorldAPI
AdaWorldAPI marked this pull request as ready for review October 20, 2026 18:42
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-20T18:44:23.585212Z 2611fd9 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Oct 20, 2026

Copy link
Copy Markdown

Add Carrot credits or activate Agent usage billing to use Autofix

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 2611fd9498

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +143 to +147
time(scalar).as_secs_f64() * 1e6,
time(simd).as_secs_f64() * 1e6,
time(|| column_in_mask(&rows, 0, &needles)).as_secs_f64() * 1e6,
time(|| rows_under(&rows, &mask)).as_secs_f64() * 1e6,
time(contiguous).as_secs_f64() * 1e6,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare equivalent outputs in the SIMD benchmark

For every contiguous_us value, this closure returns only a bit mask, while scalar_us times scalar(), which filters and collects full [u32; 2] rows; the analogous mask-to-row work is reported separately as collect_us but is never included in the contiguous result. Consequently the §2c break-even claim and column-major recommendation compare different stages, particularly when many rows match. Time a scalar mask producer or materialize rows from the contiguous mask before comparing them.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct: the contiguous arm returned the mask, while the strided arms returned rows. #1633 (a31c61bb) changes that arm to return rows_under(&rows, &m) and asserts that the result equals scalar(), so all arms are timed on the same output. The §2c numbers will be re-measured with that change.


Generated by Claude Code

@AdaWorldAPI
AdaWorldAPI merged commit 5456759 into main Oct 20, 2026
13 checks passed
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.

2 participants