perf(r2rml): PR-4d batched-OPTIONAL seed coalescing (F14) — one inner scan for the whole driving side - #1501
Closed
aaj3f wants to merge 2 commits into
Closed
perf(r2rml): PR-4d batched-OPTIONAL seed coalescing (F14) — one inner scan for the whole driving side#1501aaj3f wants to merge 2 commits into
aaj3f wants to merge 2 commits into
Conversation
aaj3f
force-pushed
the
fix/f18-q031-memo-limit
branch
from
July 15, 2026 17:12
5aeaa19 to
7fc6ef5
Compare
…for the whole driving side Coalesce the whole (bounded) driving side into one seed so a correlated batched-OPTIONAL inner is scanned ONCE rather than once per outer batch (the F14 per-window re-scan). Gated to the hash-join-safe path via supports_seed_coalescing(); own kill switch FLUREE_R2RML_OPTIONAL_SEED_COALESCE (default on) + cap FLUREE_R2RML_OPTIONAL_SEED_COALESCE_CAP (min-with-LIMIT via natural required exhaustion; 512K default, degrades to cap windows beyond). Off = single-batch pull, byte-identical. Batch::schema_arc() helper for the column-wise concat. Two hermetic tests: concat/order preservation + N driving batches collapse to one build_batch.
Contributor
Author
|
Consolidating at maintainer request. #1501 (PR-4d — batched-OPTIONAL seed coalescing) is carried forward in #1507 (the R2RML/Iceberg virtual-dataset performance program), which brings the #1475–#1507 lineage forward as a single reviewable unit. Its verification of record is the program's corpus benchmark, published as C2-bench-wave1.md (native == virtual, 0 hash mismatches). The pre-consolidation branch tip is preserved at tag |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
The batched correlated-OPTIONAL hash-left-join (
optional.rs) seeded and scanned its inner once per OUTER (driving) batch. When the driving side emits many small windowed batches (a fact scan under a LIMIT budget), the inner table is re-scanned per window — the F14 residual left after PR-4b/4c collapsed the per-row rebuild. PR-4d coalesces the whole (bounded) driving side into one seed so the inner is scanned once.Mechanism
OptionalOperator::next_batchcalledbuild_batchonce per required batch. Newpull_coalesced_requiredconcatenates required batches (column-wise, viaBatch::schema_arc()) up to a cap into one combined batch, sobuild_batchseeds the inner over the whole distinct correlation set at once. Gated to the batched hash-join-safe path viaOptionalBuilder::supports_seed_coalescing()(default false;PlanTreeOptionalBuilder= true iff every inner pattern is hash-join-safe) — so only the batched-OPTIONAL family (q016/q050) changes; every other OPTIONAL keeps the streaming single-batch pull.FLUREE_R2RML_OPTIONAL_SEED_COALESCE(default on). Off ⇒ single-batch pull, byte-identical.FLUREE_R2RML_OPTIONAL_SEED_COALESCE_CAP(default 512K rows). A LIMIT-bounded driving side exhausts below the cap (… LIMIT kcoalesces exactly the ≤k rows into one scan); beyond the cap it degrades to cap-sized windows (still ≫ the pre-PR-4d one-per-outer-batch).Gate — REQUIRED per-head full-corpus baseline (priming + 3-rep, cache-thrashed, per-query manifest timeout)
Oracle correctness: 54 records, 0 hash mismatches, 0 perf violations. (The prior mini-gate compared nothing to the blessed oracles; this is the real check.)
scan_tablescan_tableresult_hash373c16256315373c16256315(byte-identical)parquet_read):load_table1.55 s (n=1) +parquet_read4.77 s (n=23,010 = 3× full 7,670-file fact reads, ~1.6 s/scan) + ~11 s hash-left-join partition/materialize (a full 180 K-row FACT_SHIPMENT inner scan + 5000-bucket combine). q016's ≤3 s path is a future follow-on (PR-2a decode-wall for the fact scans + an IN-set-probe materialization lever), tracked in the audit ROADMAP — not the loadTable-cache alone.Tests
pr4d_pull_coalesced_required_concatenates_all_batches_in_order— 3 batches (2+1+3) → one 6-row seed, order preserved.pr4d_multi_batch_driver_collapses_to_one_build_batch— 3 driving batches ⇒ exactly ONEbuild_batch(one inner scan); all 6 left-join rows survive.fluree-db-querylib suite 1237 passed, 0 failed (incl. the existing batched-vs-per-row differentials).Design:
docs/audit/2026-07-virtual-dataset-perf/19-pr4d-optional-seed-coalesce.md(F14).