Repository navigation
feat(io): add frugal caching and dynamic I/O - #1908
Conversation
|
Testing distribution workflow here: https://github.com/sirius-db/sirius/actions/runs/36458738691 |
329fd8b to
844d2cc
Compare
Extends the prefetching cache's chunk state machine and the metadata
store so a scan can serve out of a chunk while the tail of it is still
in flight, and moves the eviction / dispose knobs to plain config
fields. Tests cover the new stage machines, arbitration between
readers and the evictor, and both eviction strategies.
Files:
src/include/io/cache/{config,types,metadata_store,prefetching_cache}.hpp
src/io/cache/{metadata_store,prefetching_cache}.cpp
test/cpp/io/cache/{test_chunk_state,test_cache_read_arbitration,
test_dispose_eviction,test_explicit_eviction,
test_stage_machines}.cpp
Reactors now own physical chunking, alignment, staging allocation, and
readv fusion; the ioctx surface delegates to them through a bulk
prepared-slice API (host_readv_async_io / device_readv_async_io /
mixed_readv_async_io). Adds warmup(), align_and_coalesce, and per-
backend prefers_bulk_io / merge_gap_size / min_alignment_requirement so
the readahead can size against what each backend can actually absorb.
Includes the S3 REST -> io/rest namespace and file layout normalization
that the new reactor contract required, and drops the vestigial
io/s3/s3_object_ref.hpp.
Files:
src/include/io/{io_context,io_request,io_errors,types,
templated_ioctx,datasource_factory,sirius_datasource}.hpp
src/io/{io_context,datasource_factory,sirius_datasource}.cpp
src/include/io/rest/**, src/io/rest/**
src/include/io/uring/**, src/io/uring/uring_reactor.cpp
src/include/io/kvikio/**, src/io/kvikio/kvikio_context.cpp
src/io/s3/sirius_httpfs.cpp
test/cpp/io/**, test/cpp/config/test_object_store_config.cpp
test/cpp/utils/s3_container.cpp
test/cpp/integration/test_s3_*.cpp
test/cpp/scan_manager/test_{s3_routing_cutover,describe_parquet_s3}.cpp
Deletes:
src/include/io/s3/s3_object_ref.hpp
Updates the design docs, tpch-performance harness, IO micro-benchmarks
and Claude skill files to describe and exercise the new cache /
reactor / readahead surfaces landing in the parent commits.
Files:
.claude/skills/{benchmark,optimization-advisor,profile-analyzer}/SKILL.md
docs/super-sirius/{configuration,multi-gpu-architecture,operators,
optimizations,scan}.md
Makefile
test/tpch_performance/{CLAUDE.md,nsys_report.sh,performance_test.py,
tpch_pin_columns.py}
test/io/*.{cpp,hpp}
844d2cc to
8396fd8
Compare
test_kvikio_remote.cpp and test_uring_readv.cpp landed via sirius-db#1908 after the catch2 branch's original migration commit and were pulled in by a later merge from main, still using the removed Catch2 v2 matcher API.
…ltered decode, and key-type generalization (INT8..UINT64, DATE/TIMESTAMP, DECIMAL, STRING, nullable keys) (sirius-db#1557) > **2026-09-29: rebased onto `main` at `b729ac0c` (the repo's default branch was renamed from > `dev`) and review round 2 addressed.** Head `8c131452`; previous tip `b04aba21`. Two commits: > `092db3d9` is the PR itself (rebased; rebase-only conflicts in `CMakeLists.txt` -> main's > per-directory source lists, the publisher's new publication-session `try` block from sirius-db#1843, and > the scan operator's `snapshot.entries()` loop), and `8c131452` holds only the changes made in > response to @joosthooz's seven threads, so the review delta is isolated: > > - **Narrowed build keys are published uniformly** (thread 1, the "silently dropping probes" > one): the DATE-only cast and the `==` zone-map gate are replaced by one domain rule > (`membership_same_family`); zone-map bounds are always restored to the recorded type, and > membership filters are pushed only to bindings whose probe type the domain can read > (`membership_probe_compatible`, counted in `bindings_skipped_incompatible_probe`). New tests: > INT64 key from an INT16 build, DECIMAL64 key from a DECIMAL32 build, compat gate. > - **One source of truth for the carrier rule**: `sirius::value_fits<To>(v)` > (`helper/numeric_carrier_rule.hpp`, `__host__ __device__ constexpr`) is used by the device > `probe_key_convert` and the host `numeric_range_fits`; `integer_storage_type` is the single > timestamp->integer mapping (all units map; the narrowing helper deliberately applies it to DATE > only, documented); `column_values_fit` in `numeric_narrowing` replaces the decimal-specific fit > check; `narrow_domain_of(cudf::data_type)` is the one carrier-family list. > - **Device == host test**: every (rep, carrier) pair at every boundary value vs `value_fits`. > - **Dedup**: `compute_mask` prior-free forwarder defined once in `sirius_mask_applicable`; > constructor prologue shared as `prepare_membership_build`; probe kernel prologue/launch shared > as `membership_probe_functor` / `run_membership_probe`, each filter contributes only its lookup. > > Kernel count unchanged (19 per filter kind). Verified at `8c131452`: release + clang-debug > builds clean; `[dynamic_filter]` 306/306, `[fused_scan_filter]` 27/27, `[numeric_narrowing]` > 14/14; full `make test` 3677/3680 with the 3 failures being a since-fixed assertion in the new > narrowing test (tag re-run green) and two environment/flaky cases unrelated to this PR > (`sirius_config forces the sirius backend for multi-GPU` on a 1-GPU host; `test_explicit_eviction` > from sirius-db#1908 passes in isolation). `pre-commit run -a` clean. > > **2026-09-21: rebased onto `dev` at `b1909fcc` and squashed to one commit** (new head > `b04aba21`; previous tip `743eed39`, incl. the review-cleanup commit, is preserved on the > fork as `pr/carrier-native-df-probes-rebased-dev`'s ancestor and in the reflog). Squashed > because sirius-db#1817 (`rmm::cuda_stream_view` -> `cuda::stream_ref`) rewrote the signatures every one > of the 8 commits touched, so a per-commit rebase conflicted 8 times over. Adaptations to dev: > > - **sirius-db#1806 header split**: `src/include/` is gone; the new files now live beside their sources > (`src/cuda/dynamic_filter_probe.cuh`, `src/op/dynamic_filter/dynamic_filter_key_domain.hpp`) > and the `selection.hpp` edit followed that header to > `src/compression/simpatico_codegen/src/codegen/selection/`. Include paths are unchanged. > - **sirius-db#1817 stream migration**: all PR code and tests use `::cuda::stream_ref` (`.get()`, > `.sync()`); no `cuda_stream_view` remains in PR-touched files. > - `restore_probe_to` call sites that dev still had are gone with it; no references remain. > > Verified at `b04aba21`: `pixi run make` and `pixi run make clang-debug` both clean, > `[dynamic_filter]` 277/277, `[fused_scan_filter]` 27/27, `make test` 3367/3367 on an idle GPU, > `pre-commit run -a` clean. > > **2026-09-17: scope extended.** Six commits (`d219a326`..`b352168c`) generalize the > membership probes to every fixed-width integer, DATE/TIMESTAMP, DECIMAL, STRING and nullable > keys via a key-domain dispatch layer — see **section 3** below. Head moved `80801eb1` -> > `b352168c`; full `make test` 3293/3293. > > **2026-09-16: rebased onto `dev` at `f54e6a10`** (new head `80801eb1`; the previous tip > `30fe3dd9` is preserved on the fork's reflog and referenced here). Still a single commit. > Three files conflicted: > > - `CMakeLists.txt` — test-source list; kept both dev's new iceberg/puffin tests and > `test_fused_membership_mask.cpp`. > - `src/cuda/sirius_dynamic_bloom_filter.cu` — include block only. Dev (sirius-db#1809) dropped the > custom `sirius_bloom_policy` in favour of `cuco::default_filter_policy`, so the > `<cuco/hash_functions.cuh>` include this PR carried is dead and was dropped too; the > `bloom_contains` Bulk kernel is unchanged. > - `src/compression/simpatico_codegen/src/simpatico_codegen.cpp` — dev landed the T9 > positional keep mask (sirius-db#1556) as an extra AND source appended *after* wave 1, while this > PR moves the combine *before* the sequential membership cascade. Resolved by making the > keep mask a cascade prior: it is uploaded on `s0` before the combine and counts as > "another source", so a membership-only chunk *with* a keep mask now takes the sequential > pruned path. With no static range/bool8 strip nothing else writes `combined`, so the keep > mask lands there directly instead of a separate strip. The "every probe declined" fallback > is unchanged and still correct on that path (`keep_mask_applied` stays false, the caller > applies the mask itself). A new case in `test_fused_membership_mask.cpp` covers it. > > The "Deliberately not carried over" paragraph below is therefore partly stale: the T9 > keep-mask **is** now a prior source; pair (col-vs-col) filters remain out. > > Verified on this rebase: `[dynamic_filter]` 241/241, `[fused_scan_filter]` 22/22 (5 fused > membership cases), `make test` 3257/3257 — 36 `gpu_execution iceberg` cases failed on the > first pass only because the `iceberg` DuckDB extension was not provisioned on the box; > all 36 pass after `INSTALL avro; INSTALL iceberg`. `pre-commit run -a` clean. > **Rebased onto `dev`.** This PR previously sat on the closed fused-scan-filter > (sirius-db#1391) + late-mat (sirius-db#1409) stack — the "wave-2 lineage" the old description > referred to. Both were reimplemented and merged as sirius-db#1474 and sirius-db#1524, so the > branch is now a **single commit off `dev`** with no base-branch diff > pollution. The old wave-2 tip is preserved at `a9ac3d88`. ## 1. Carrier-native probes `compute_mask` on all three membership filters required the probe column's type to equal the filter set's type. Compressed materialization stores a bounded `BIGINT`/`INTEGER` key in the narrowest fitting signed carrier, so a decode-time probe sees `INT32` against an `INT64`-built set. The probes now accept any signed-integer carrier (`INT8`..`INT64`) and convert per element in-kernel. A value the key domain cannot represent is a definite non-member, so the no-false-negative contract holds. ### This replaces `restore_probe_to`, and the two were measured against each other sirius-db#1555 fixed the same defect by materializing a widened copy of the probe column before the lookup. The two are **independent fixes for the same problem, derived two weeks apart** — neither the wave-2 base nor T2's own branch had `restore_probe_to`; it appeared during sirius-db#1555's own rebase. Merge order rather than merit picked the winner, so I A/B'd them. Pooled allocator (production hands these calls a pooled `mr`; an unpooled one charges the restore a driver allocation the real path never pays), both arms interleaved in one process, median of 15 warmed reps: | filter | rows | filters/col | A: restore | B: in-kernel | B/A | |---|---|---|---|---|---| | hash IN-list | 1M | 1 | 23.6 µs | 19.0 µs | **0.81** | | hash IN-list | 8M | 1 | 92.1 | 67.7 | **0.74** | | hash IN-list | 8M | 3 | 256.4 | 200.5 | **0.78** | | Bloom | 1M | 1 | 19.6 | 16.2 | **0.82** | | Bloom | 8M | 1 | 67.0 | 46.1 | **0.69** | | Bloom | 8M | 3 | 178.7 | 117.9 | **0.66** | In-kernel is faster at **every point measured**, across two independent runs, and both arms produce identical masks (asserted in the harness). The margin widens with filters per column because `restore_probe_to` sits *inside* `compute_mask` and so re-materializes the same column once per filter — which the post-decode cascade in `dynamic_filter_merge` does routinely, on the default path, not just under the experimental gate. Read the pooled numbers as a **lower bound**: the benchmark pool is fresh, dedicated and uncontended, so production's allocation costs at least this much. Scale: ~3 µs per million rows, so ~18 ms for a full lineitem probe pass at SF1000. Real and consistent, but modest in absolute terms — this is not a headline win, and nothing here recovers the number the old description claimed. `restore_probe_to` had no other callers and is removed with its helpers. ## 2. Mask-aware probing `sirius_mask_applicable` gains a prior-keep-mask `compute_mask` overload (packed 1 bit/row); dead rows skip the set/Bloom lookup. The wave-1 orchestrator runs membership probes sequentially on `s0` after combining the other mask sources, handing the combined words to each probe as its prior and folding each result back in, so later probes see earlier survivors. Membership-only chunks keep the concurrent, prior-free path. The prior is a hint only: ignoring it is sound because the caller ANDs with that same mask. **This half is unmeasured and is the open question on the PR.** It trades concurrency for pruning: a probe that previously ran round-robin on its own pool stream now serializes on `s0` behind the combine, and only the lookup is pruned — the full-width key decode is still paid. At high static keep-rate that may not pay for the lost overlap. **Reasonable to split out** if you'd rather land item 1 on its own measurement and take item 2 separately. ## 3. Key-type generalization: membership probes beyond `INT32`/`INT64` (added 2026-09-17, commits `d219a326`..`b352168c`) Item 1 fixed the *carrier* mismatch for integer keys. This section removes the *type* gate entirely. All three membership filters (hash IN-list, small IN-list, Bloom) previously accepted only `INT32`/`INT64` keys with `null_count()==0`; any other equality key reached the publisher and was silently assigned no membership filter (`choose_membership_filter` -> `none`). Type gating lived in three places, none of them the planner: the filters' `supports()`, the publisher's build-column type-equality check, and the join-edge route gate in the publish plan. ### Dispatch design Two orthogonal, explicitly enumerated axes instead of a `cudf::type_dispatcher` over the (key, probe) type pair (which would instantiate hundreds of kernels): - **Key rep** — the device element type the set / needles / Bloom are built over: `int32_t`, `int64_t`, `uint32_t`, `uint64_t`. New host-only header `src/include/op/dynamic_filter/dynamic_filter_key_domain.hpp`: `membership_key_family` `{signed_int, unsigned_int, date_days, timestamp, decimal, string_hash}`, `classify_membership_key`, `membership_key_supported`, `membership_probe_compatible`, `membership_build_fits_rep`. These replace every `INT32|INT64` literal in the three `supports()`, the publisher, `dynamic_filter_publish_plan.cpp`, and `direct_route_admissible`. - **Probe adapter** — a device functor chosen on the host from `(domain, probe.type())`: `integral_probe_adapter<ProbeRep, KeyRep>` (generalizes item 1's `probe_key_convert`; signedness-aware, range-checked, sentinel-aware), and `string_hash_adapter`. Kernels (`set_contains`, `small_in_list_scan`, `bloom_contains`) take the adapter, a `probe_validity` bitmask reader and the optional prior keep-mask, and emit a **non-nullable** `BOOL8` mask. Instantiation budget: **19 probe kernels per filter kind** (was 8 on dev, 16 for the integer scaffold, +2 for `__int128` decimal carriers, +1 string). Compile time per `.cu` unchanged within noise (~30 s each, measured cache-busted). ### What each family does | Family | Rep | Build side | Probe side | Notes | |---|---|---|---|---| | `INT8`/`INT16`/`INT32`/`INT64`, `UINT8`..`UINT64` | i32/i64/u32/u64 | any signed/unsigned integer column; the publisher now **accepts a build column arriving at a narrower carrier** when `can_restore_to` holds (previously the key was skipped, `keys_skipped_type_mismatch`) | any carrier of the same signedness family, converted in-kernel; out-of-domain value = definite non-member | sentinel is `min()` for signed, `max()` for unsigned reps | | `TIMESTAMP_DAYS` (DATE), `TIMESTAMP_{S,MS,US,NS}` | i32 / i64 | reads the underlying rep; a DATE build column arriving as `INT8`/`INT16` is **restored to `TIMESTAMP_DAYS`** in the publisher (a carrier-typed set would decline the native probe the post-decode cascade emits) | same unit, or `INT8`/`INT16`/`INT32` carriers for DATE; mixed units decline (unreachable anyway: DuckDB inserts a cast and a cast blocks the scan route) | zone maps already supported these and serve as the test oracle | | `DECIMAL32`/`DECIMAL64`/`DECIMAL128` | i32 / i64 / i64-if-fits | `DECIMAL128` builds are range-probed (`compute_exact_numeric_range`); if the unscaled range fits `int64` the set is `int64`, else **all three membership filters decline** (zone map still publishes) | same scale required; `DECIMAL32`/`64`/`128` carriers all accepted, `__int128` probes range-checked into `int64` | no `__int128` Bloom (deliberately) | | `STRING` | u64 | `cudf::hashing::xxhash_64` fingerprints materialized once per build | `XXHash_64<string_view>` computed **in-kernel** over a `column_device_view`, no materialized copy; `DICTIONARY32` declines (the fused decode reconstructs dictionary/str_split carriers to `STRING` first) | both IN-lists become **no-false-negatives** for strings (fingerprint collisions keep rows); the sentinel `UINT64_MAX` needs no remap — cuco's insert of its empty key is a no-op and the probe keeps rows whose fingerprint equals it | | **nullable keys** (any family) | — | `supports()` no longer requires `null_count()==0`; null build keys are compacted out (`drop_nulls`, as Bloom already did); the small IN-list tier gates on *valid* rows; the publisher sizes/tiers on `valid_rows` | null probe rows emit `false` via the `probe_validity` prologue; `copy_bitmask` tails removed | exact, not approximate: null-safe keys are never admitted and the join runs `null_equality::UNEQUAL`, so a NULL never matches on either side | Not done, on purpose: `FLOAT32/64` (no benchmark uses float keys; would need -0.0/NaN canonicalization), `BOOL8`, `LIST`/`STRUCT`, `HUGEINT` (its lossy `INT64` mapping is a separate bug). ### Where the expected TPC-H wins turned out not to exist TPC-H has **only `INTEGER`/`BIGINT` join keys**, so this section is inert on TPC-H beyond the narrow-build-carrier acceptance and nullable-key handling. In particular: - q2's `ps_supplycost = min(...)` is planned as a `FILTER` above a `DELIM_JOIN`, not as a join condition — there is no DECIMAL join key to admit. - q15's `total_revenue = (subquery)` *is* a DECIMAL128 join condition, but its build side is `AGGREGATE max(...)` over a `CTE_SCAN`, which `build_relation_is_opaque` / `build_subtree_is_filtering` do not recognize as evidence. That is the evidence policy, upstream of admission, and is untouched here. The beneficiaries are TPC-DS. A survey at SF10 on the integer-only scaffold found that of the 21 queries with STRING/DATE/DECIMAL/nullable join keys, only ~7 currently run on the GPU at all (the rest fall back on UNION / WINDOW / DISTINCT / mixed-inequality joins, or crash: q10 aborts on a MARK-join mode assertion). Those seven *do* show the key being declined today: q83 (`d_date` -> `none`), q59 (`s_store_id` -> `none`), q30/q81/q64/q69 (nullable INT keys downgraded IN-list -> Bloom). No TPC-DS timing is claimed in this PR. **SF1000 TPC-H QphH, same recipe as August, no patched libcudf:** dev `f54e6a10` 7.79M (Power 10.15M / Tput 5.98M); this branch at `80801eb1` (items 1+2 only) median of 3 clean runs 7.95M (Power 10.45M / Tput 6.04M) — Power +3.3%, inside the ±4.5% run-to-run band. Firmer than the score: dev hit GPU-OOM retry-cap CPU fallbacks in 3 of 4 throughput phases, this branch in 0 of 3. Per-query the membership-filter consumers moved most (q17 −11%, q8 −9%, q7/q20 −7%, q19 −6%). The type-generalization commits were not scored separately: they cannot change any TPC-H plan. **Re-measured 2026-09-21 at the rebased head `b04aba21` vs dev `b1909fcc`** (4 clean interleaved runs each, medians): Power 10.49M vs 10.19M (+2.9%), Throughput 6.02M vs 5.99M (+0.5%), QphH **7.94M vs 7.83M (+1.5%)**, stream-0 7.85 s vs 8.07 s. All four PR Power values sit above all four dev values; q19 −17%, q17 −11%, q8 −7%, q20 −6%, q7 −5%; nothing slower than dev by >0.3%. Side finding, not caused by this PR: on this dev base the 7-stream throughput phase hits GPU-OOM retry-cap CPU fallbacks in 6 of 10 dev attempts (2 of 6 with the PR; 0 of 1 on the f54e6a1-based control), which then either kills the streams on DuckDB's 32 GB limit or spills hundreds of GB to disk. Power phases are unaffected. ### Tests for this section `[dynamic_filter]` 277 cases / `[fused_scan_filter]` 27 cases; full `make test` 3293/3293 on an idle GPU at `b352168c`. New coverage, per family and for all three filters, with and without a prior mask, against a host oracle and (for DATE/DECIMAL) the lowered zone-map AST as an independent oracle: cross-carrier identity `INT8..INT64` x `{INT32,INT64}` keys vs. the old path; `INT8`/`INT16`/`UINT*` keys and unsigned sentinel semantics; `TIMESTAMP_DAYS` x `{DAYS, INT8, INT16, INT32}` probes and unit-mismatch declines; `DECIMAL{32,64,128}` x `DECIMAL{32,64,128}` probes, scale mismatch declines, DECIMAL128 fit -> int64 set vs. overflow -> decline; STRING host XXH64 reference pinned against `cudf::hashing::xxhash_64` over a corpus covering every XXH64 tail path (empty, 1 KiB, UTF-8, embedded NUL); nullable builds x nullable probes x 4 carriers, sliced-probe offsets, all-null build/probe; publisher accepting `INT8`/`INT16` build carriers, `DECIMAL32`-carrier for a `DECIMAL64` key, `INT16`-carrier DATE; fused decode of `INT8`-carrier, `INT16`-carrier-DATE, `DECIMAL32`-carrier and dictionary-`STRING` chunks against the widened sets. `docs/super-sirius/dynamic-filters.md` gains a "Key types" section with this table. ## The original's numbers do not transfer The old description claimed SF1000 Power **+7.2%**, q19 **−52%**. Those were measured against a stack where a declining probe *threw* and failed the entire filtered decode. sirius-db#1524 changed that to a stand-down to the AND identity, and sirius-db#1555 removed the decline for narrowed carriers altogether. **Treat the old numbers as void.** ## Notes - **The multi-probe cascade is unreachable in a default build.** `SIRIUS_EXP_FUSED_SCAN_MAX_MEMBER` defaults to `1`, so the fold-back never executes; the new test arms it to 2. Worth deciding whether that default moves. - **Small-in-list was not benchmarked** — the A/B covered hash IN-list and Bloom. - Item 2's decode-time path sits behind `SIRIUS_EXP_FUSED_SCAN_FILTER` (off unless set). Item 1 is on the default path via the post-decode cascade. ## Deliberately not carried over `dev`'s reimplementation dropped pair (col-vs-col) filters and the T9 visibility keep-mask (still open as sirius-db#1556), both of which the original also primed priors from. Priors here are ranges and dictionary-answered equalities only. A declining probe in the sequential cascade leaves the mask untouched, matching `dev`'s all-ones stand-down rather than the original's throw. ## Related, not fixed here The build side has the mirror defect with a worse failure mode: `dynamic_filter_publisher.cpp` compares the runtime build column against the plan's recorded logical type and **skips the key entirely** on a mismatch (`keys_skipped_type_mismatch`), so a narrowed build key publishes no filter at all — probe-side tolerance cannot help there. Already instrumented via `dynamic_filter_stats`; worth checking whether that counter fires. ## Tests - `test/cpp/operator/test_dynamic_filter_probe.cpp` (`[dynamic_filter][probe]`, 8 cases): heterogeneous carriers, decimal/date/float refusal, sentinel conservation, prior-mask all-dead/all-live/patterned, null propagation. - `test/cpp/scan/test_fused_membership_mask.cpp` (`[fused_scan_filter]`, 4 cases): prior handed alongside a static range, prior-free membership-only, a two-probe cascade proving the fold-back, all-dead prior, INT32 carrier vs INT64 set. Against current `dev`: `[probe]` 8/8, `[fused_scan_filter]` 4/4, `[dynamic_filter]` 240/240, **full suite 3035/3035** (32,788,590 assertions). `pre-commit` clean. The A/B harness was scaffolding and is not in the diff. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5 <[email protected]>
|
After
auto reader_options = _run_reader_options ? _run_reader_options : _reader_options;
auto per_slice_ranges = slice_column_chunk_ranges(_slices, *reader_options);
auto hints = parquet_fadvise_entries(_slices, per_slice_ranges);
auto split = std::make_unique<parquet_split_info>(std::move(hints));
split->rg_slices = std::move(_slices);
split->reader_options = std::move(reader_options);
split->set_column_chunk_byte_ranges(std::move(per_slice_ranges));
for (std::size_t i = 0; i < slices.size(); ++i) {
if (!slices[i].file_metadata) { continue; }
per_slice[i] =
column_chunk_ranges(*slices[i].file_metadata, reader_options, slices[i].row_group_indices);
}
if (row_group_indices.empty()) { return {}; }
hybrid_scan_reader reader(metadata, options);
return reader.all_column_chunks_byte_ranges(
cudf::host_span<cudf::size_type const>(row_group_indices.data(), row_group_indices.size()),
options);cuDF 26.08.01 copies the hybrid_scan_reader::hybrid_scan_reader(FileMetaData const& parquet_metadata,
parquet_reader_options const& options)
: _impl{std::make_unique<detail::hybrid_scan_reader_impl>(
std::vector<FileMetaData>{parquet_metadata}, options)} // initializer list + vector element
{
}
// aggregate_reader_metadata(host_span<FileMetaData const> ...):
std::transform(parquet_metadatas.begin(), parquet_metadatas.end(),
std::back_inserter(per_file_metadata),
[](auto const& parquet_metadata) { return metadata{parquet_metadata}; });
initialize_internals(use_arrow_schema, has_cols_from_mismatched_srcs);
// hybrid_scan_helpers.hpp:39
explicit metadata(FileMetaData const& other) { static_cast<FileMetaData&>(*this) = other; }So the cost scales with all row groups and columns in the file, not with the slice, and it runs on the serial if (!datasource || !datasource->uses_prefetching_cache()) { return; }
auto ranges = std::forward<RangeFactory>(make_ranges)();With The gate we measured, applied at - if (!slices[i].file_metadata) { continue; }
+ if (!slices[i].file_metadata || !slices[i].datasource ||
+ (!slices[i].datasource->uses_prefetching_cache() &&
+ !slices[i].datasource->prefers_bulk_io())) {
+ continue;
+ }
Measured on parent
With page-cache reads, Q6 on the 4,096-row data was 2.28-2.32 / 3.96-4.22 / 2.51-2.68 s over two runs: the gate removes most of the extra CPU work, with a small residual. The parent harness issued |
…ode (sirius-db#1946) ## Summary Reading several Parquet files from S3 in one query can return wrong results when a column's type differs between the files. For example, if `a.parquet` stores `x` as INT32 and `b.parquet` stores `x` as DOUBLE, `SELECT sum(x) FROM read_parquet('s3://bucket/prefix/*.parquet')` returns a wrong sum on the GPU, with no error. On the REST backend (the default for `s3://`), a scan split (a batch of files decoded together) that holds several files is decoded by cuDF's `hybrid_scan_multifile`, which, with the reader options Sirius uses, decodes every file with the first file's schema and does not check that the other files match it. The general route (`cudf::io::read_parquet` over several sources, used for local files and for `backend: kvikio`) makes that check and fails with "All sources must have the same schema". Before sirius-db#1908, S3 splits went through the general route as well. This PR adds the same check to the bulk route. Before the bulk materializer fetches column chunks, it compares each file's footer schema with the first file's, using the same comparison as cuDF's general reader (which does not look at logical types). A mismatch reports both paths and either the differing schema sizes or the first mismatched element. The check is per scan split; single-file splits and the general route are unchanged, and files that land in different splits are still decoded one by one as before. ## Behavior change Files whose schemas differ only in writer metadata, for example a DuckDB-written file next to a pyarrow-written one (different root names, and an `INT_32` annotation on one side only), are now rejected on this route too. This matches the general route and the S3 behavior before sirius-db#1908. Supporting mixed schemas is outside this fix. ## Tests - Unit (`test_parquet_helpers.cpp`, `[bulk_schema]`): the bulk route rejects drifted files before reading any column chunk; the comparison accepts a shared schema and rejects a different column order, an extra column, a root-name-only difference and an annotation-only difference. - S3 (`test_s3_sql_surface.cpp`): a glob over two MinIO objects whose `x` is INT32 in one and DOUBLE in the other now fails with the schema error instead of returning a wrong sum. - Local run on one RTX 3060: `make s3-test` (98 cases), `make s3-test-large` (5 + 3 cases), 3,644 unit cases across two runs with `--order decl` over `~[.]~[multi_gpu]` (3,577 excluding VSS, then the 67 VSS cases), and a build with `SIRIUS_BUILD_S3_TESTS=OFF` running `[bulk_schema]` (4 cases), all passing. The PR also corrects two sentences in the S3 test README that described Catch2 v2's tag listing: Catch2 v3 lists hidden cases with `[.]` only, so `--list-tags "[s3]"` shows the 26 documented tags plus `[.]`.
…ius-db#2024) ## Description sirius-db#1908 reintroduced `sudo tee /proc/sys/vm/drop_caches` in performance_test.py (undoing sirius-db#1470) and gated --mode/--profile cold on passwordless sudo, so benchmark runs abort on nodes without the sudoers rule. Evict the dataset files with posix_fadvise(DONTNEED) again; can_drop_os_cache() is removed. (More context; this will help fix the nightly gb300 benchmarks) ## Checklist - [x] Read CONTRIBUTING.md and ensure PR meets "reviewability" checklist - [x] Cover changes with new or existing tests - [x] Document configuration changes in code and summarize in the description above - [x] Update human and agent documentation (README.md, docs/, skills, CLAUDE.md) ## References Co-authored-by: Claude Sonnet 5.5 <[email protected]>
Frugal IO (34f89ba, sirius-db#1908) and the dense count-join fixes (54d1b17, sirius-db#1766) landed upstream as squashes of work this branch had merged earlier, so files touched only by that work take upstream's version. This branch's own commits on top of them were re-applied: REST read counters, fused object-store reads, multi-file read overlap, rest.max_connections, and the late-mat scan commits. Adapted to upstream's refactors: src/include -> src, per-directory CMake source lists, ::cuda::stream_ref, query_event_publisher, lock_and_prepare_batch_result, and downgrade_request::target_bytes (replacing requested_bytes). Dropped: the scheduler stall watchdog (it read a single _query; the scheduler is now multi-query), the ctrack aggregate report, and the LUMP-only query_stage_manager / stream_ordered_retirer / prefetch_census, which upstream's squash did not keep. cucascade now points at a350613 (try_release_table ported onto cuCascade main, taking a stream like release_table). merge-guard passes; the build is clean; unit tests not yet run on this merge. Co-Authored-By: Claude Opus 5.5 <[email protected]>
- .hpln reads go through sirius_datasource::host_read_ranges_async (one slice per destination; the sirius-db#1908 reactors fuse and split), replacing the removed io_object_segment path and the kvikio one-by-one fallback. - Plan generator includes sirius_registration.hpp for the read_simpatico bind data. - Tests: SeaweedFS S3 harness names (sirius-db#919), ContainsSubstring matcher, shared_ptr<pinned_entry const> providers, scan_manager_config fields removed by sirius-db#1908. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…tores Since upstream sirius-db#1908 a read batch goes to a single uring reactor instead of being divided across all of them, so the .hpln reader's request size -- 16 MiB, measured against S3 -- now caps a local read at one ring's 16 MiB throughput (~17 GB/s against the RAID's ~22). SF1000 .hpln pin: 13.2 s -> 10.3 s (16/64/128 MiB = 13.2/10.35/10.39 s); cold suite unchanged. The open options' policy becomes optional and an unset one takes the opened source's default: local_file() for local transports, the S3-measured defaults for the REST backend. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…chema
use_sirius_datasource and enable_prefetch_cache were removed upstream and are
now rejected at load; their equivalents are backend: sirius and
cache: {mode: none}. sirius-sf1000.yaml goes from 1 to 8 uring reactors: after
sirius-db#1908 one reactor serialises reads (cold SF1000 parquet 210 s vs 60 s at 8);
8 beats the new default of 4 by ~20% on cold parquet.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
…e object changed (sirius-db#2036) ## Description **Bug (before this fix).** With REST-backed S3 reads and `scan_manager.cache.mode: sirius` (LRU eviction is the default), cached chunks could survive an in-place overwrite and silently supply old bytes, or combine cached old ranges with newly fetched ranges. Queries could therefore return stale results without an error. The cache keyed entries only by path, even when the object's ETag changed. Parsed Parquet footers had the same path-only identity, so stale schema/metadata could also be reused with byte caching disabled. DuckDB's external-file-cache ETag checks did not invalidate these underlying Sirius entries. Reproduction outline on the old code: keep the same process/cache alive, query data from `read_parquet('s3://b/t.parquet')` and confirm the relevant data ranges are cached; overwrite that key with a different equal-size Parquet object and changed ETag (`aws s3 cp t_v2.parquet s3://b/t.parquet`); reread before eviction/reset. Cached ranges can return old bytes and partial hits can mix versions. The resulting SQL behavior also depends on the Parquet layout; equal size alone does not guarantee valid mixed rows. - REST byte and metadata cache keys now use path + strong ETag within the owning ioctx. New generations retire older map entries; shared ownership retains them while handles and in-flight operations use them. - Opens without a usable strong ETag lose cross-open reuse. Their GETs remain unconditional, without snapshot consistency across requests. - Strong-validator data GETs send `If-Match`. A 412 (even with a truncated error body), or a missing/weak/different ETag on an otherwise accepted 206 or full-object 200, raises `object_changed_error` without retry or caching that response. Transient retries retain the condition; prefetch errors are available through `prefetch_failure()`. A detected mid-open version mismatch therefore becomes an error instead of caching replacement bytes under the old identity. A new open uses the validator it observes; cache and footer-stash hits do not revalidate remotely. Cache-instance lifetime across `reset_sirius_cache()` versus CPU readers remains out of scope. **Tests** - SeaweedFS tests cover overwrite isolation, metadata and generation lifetime; loopback tests cover conditional failures/retries in both signing modes. - The existing eviction regression now controls pressure and queue ordering, retaining its strict assertion. ## Validation g6.8xlarge / one L4; DuckDB `069cc9f9` in both runs. S3-enabled runs use `SIRIUS_TEST_S3_AUTO=1 SIRIUS_TEST_S3_STRICT=1`. Before the rebase onto `60ca047e` (head `1719fec8`, MinIO harness, cuCascade `12f28408`): - `scripts/run_unit_tests.py --shards 1 -- --order decl`: PASS — 3848 cases / 40,005,389 assertions; late_mat 109 / 6,491. Multi-GPU step not applicable on one GPU. - `make s3-test`: PASS — 118 cases / 32,445 assertions. - `make s3-test-large`: PASS — 5 cases / 99,259 and 3 cases / 40 assertions. - GCC ASan, `[cache_identity],[cache][eviction]`, `detect_leaks=0`: PASS — 38 cases / 1,235 assertions, no sanitizer reports. After the rebase (head `b04a7887`, SeaweedFS harness from sirius-db#919, cuCascade `bd4aeedb`): - `[cache_identity]`: PASS — 27 cases / 1,071 assertions. Without an S3 environment, 13 integration cases return through the success/skip guard and 14 other cases execute (27 reported passes / 439 assertions). - `make s3-test`: PASS — 118 cases / 32,432 assertions. - `pixi run pre-commit run -a`: all hooks pass. The C2 IO source was preserved by the rebase, but the rebased tree includes other upstream changes. The full unit suite, large suite and ASan selection were **not rerun after the rebase**; their results above remain tied to the pre-rebase head. ## Checklist - [x] Read CONTRIBUTING.md and ensure PR meets "reviewability" checklist - [x] Cover changes with new or existing tests - [x] Document configuration changes in code and summarize in the description above (no configuration keys added or changed) - [x] Update human and agent documentation (`docs/super-sirius/scan.md`: object identity, conditional reads, cache generations, metadata store) ## References Follows sirius-db#1401 (ETag capture for DuckDB's external file cache) and sirius-db#1908 (LRU retention that made cross-query reuse the default).
…ouped mode again sirius-db#1908 moved LOAD ahead of the view registration in open_connection() and dropped the block that followed it, so the in-process runners stopped applying --pin-compression / --compression-plan-dir and SIRIUS_PRE_SQL. bench/sf1000-repro/run.sh passes compression, its plans and ast_jit that way, so it silently measured uncompressed pins under ast_interpret: SF1000 suite 29.3 s with q9 OOM-falling back to the CPU, against 6.79 s with the block restored. Co-Authored-By: Claude Opus 5.5 <[email protected]>
…irius-db#2083) ## Description sirius-db#1908 moved LOAD ahead of the view registration in open_connection() and dropped the block that followed it, so the in-process runners stopped applying --pin-compression / --compression-plan-dir and SIRIUS_PRE_SQL. bench/sf1000-repro/run.sh passes compression, its plans and ast_jit that way, so it silently measured uncompressed pins under ast_interpret: SF1000 suite 29.3 s with q9 OOM-falling back to the CPU, against 6.79 s with the block restored. ## Checklist - [x] Read CONTRIBUTING.md and ensure PR meets "reviewability" checklist - [x] Cover changes with new or existing tests - [ ] Document configuration changes in code and summarize in the description above - [ ] Update human and agent documentation (README.md, docs/, skills, CLAUDE.md) ## References --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
Covers the 223 upstream commits between 5e0e39e and ef23a65 (the window merged from upstream/main), verified against current HEAD source: - New optimizations entries: sirius-db#1302 (hardware decompression), sirius-db#1478 note, sirius-db#1578 (cached/fused/parallel metadata walk), sirius-db#1945 (cardinality in plan copy), sirius-db#2043 (byte-range parquet splits), sirius-db#2090 (per-file footer reader reuse), sirius-db#2156 (per-task result collection); PR numbers added to the Decimal SUM entry heading - Rewrote the stale sirius-db#1548 deferred-walk entry (deferral is now unconditional under the shared checkpoint key) and patched sirius-db#1555 (in-kernel key-domain probe conversion replaced restore_probe_to) - Grouping sets / ROLLUP / CUBE / GROUPING() (sirius-db#1991) documented in operators.md and physical-plan-generation.md; DISTINCT-only-in-COUNT fallback; join condition materialization now covers all sides (sirius-db#1840) - Transparent-path updates: provider-internal/hidden-catalog exclusion (sirius-db#1764), copy_logical_plan, CPU-replay error reporting (sirius-db#2188), Step 3/9 rewritten for the v2 single-call sirius_execute_query - Query Event Publisher: ninth event type and live publishers/subscriber (sirius-db#1908/sirius-db#1847); discard_query_tasks naming; two-sleep-site refinement - lock_or_prepare_batch -> lock_and_prepare_batch rename + Layer 3/4 rewrite across pipeline-execution, data-management, execution-flow, multi-gpu-architecture, memory-management - vector-search.md re-verified: registration via SiriusRegistration, all line references corrected, stale-index detection (table incarnation + pin snapshot, sirius-db#1591) documented - compressed-pinning: nullable-column sidecar (sirius-db#2182) and JIT kernel cache sections; dynamic-filters nullable-key limitation reworded - configuration.md: readahead/reactor defaults (sirius-db#1966), uring/rest n_max_concurrent_scans keys, static-flags table corrected, gpu_execution SET scope; streaming-fragments: static extensions + ContextConfig/Builder (sirius-db#2032) - README ToC rows for the two dynamic-filter design docs; marker bumped to ef23a65
…000 repro configs Set hash_partition_bytes to 5GB (was 32GB) and max_build_hash_table_bytes to 10GB (was 32GB, now 2x the hash partition size). Comment out the keys that restate Sirius's defaults and mark them "# default", so the files show what differs without losing the key names: memory.gpu.usage_limit_fraction (0.95, main config only; the gate config keeps its 0.80), memory.gpu.reservation_limit_fraction, memory.disk.disk_id, executor.downgrade.num_threads, operator_params.max_sort_partition_bytes, and telemetry.output_directory and engine_name. Comment out scan_manager.use_sirius_datasource and enable_prefetch_cache, which were removed in sirius-db#1908 and are rejected as unknown config keys. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
…ro configs Drop the explicit 32GB hash_partition_bytes and max_build_hash_table_bytes, and the 5GB concat_batch_bytes, from both repro configs so they use Sirius's defaults on this GPU (5GiB batch sizes, 2x the batch default build cap). The keys stay in the files, commented out and marked "# default". scan_task_batch_size keeps its tuned 8GB. Likewise comment out the other keys that restate Sirius's defaults, so the files show what differs without losing the key names: memory.gpu.usage_limit_fraction (0.95, main config only; the gate config keeps its 0.80), memory.gpu.reservation_limit_fraction, memory.disk.disk_id, executor.downgrade.num_threads, operator_params.max_sort_partition_bytes, and telemetry.output_directory and engine_name. Comment out scan_manager.use_sirius_datasource and enable_prefetch_cache, which were removed in sirius-db#1908 and are rejected as unknown config keys. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
Description
Large and remote parquet scans need to avoid eagerly reading and decoding data that a query may never consume. This adds frugal caching and dynamic I/O so physical requests can be split, aligned, coalesced, staged, and served incrementally according to each backend's capabilities.
The layer includes:
reset_sirius_cache()and updated cache/backend configuration;pin_table(..., tier='parquet')for retaining undecoded parquet ranges in the I/O cache;Tests cover cache state transitions, request planning, backend behavior, readahead lifecycle, configuration, reset behavior, and parquet scan sizing.
Validation
pixi run pre-commit run -apixi run cmake --build build/release -j 4(including all standalone I/O benchmark targets)Checklist
CONTRIBUTING.mdand meet the PR reviewability requirements.Stack
This was layer 6 of the frugal native-I/O stack; the lower layers (#1773, #1774, #1776, and #1772) are already merged. Supersedes #1771:
devwas folded intomainupstream, and this branch is now rebased directly ontomain's tip as a normal, non-stacked PR.GB300 benchmarks:
profile lukewarm. hot cold
q1 4.0062 2.7908
q2 1.0207 0.3670
q3 1.7495 1.1402
q4 1.9325 0.8274
q5 2.1787 1.1928
q6 0.9368 0.9093
q7 1.3715 1.4290
q8 2.4953 1.1644
q9 2.8493 3.0254
q10 2.5605 1.8375
q11 0.4259 0.3570
q12 1.2622 1.3134
q13 2.1456 0.9090
q14 1.1204 1.1168
q15 1.0552 0.9031
q16 0.4655 0.3556
q17 1.3752 1.2920
q18 2.6438 2.2206
q19 1.4832 1.4426
q20 1.2476 1.2262
q21 2.7803 2.7661
q22 0.3547 0.3392
Total 37.4606 28.9252
cold
Query iter0
q1 3.7907
q2 0.9496
q3 2.5600
q4 1.6931
q5 3.0860
q6 2.0780
q7 3.1990
q8 4.3953
q9 5.0900
q10 3.2508
q11 0.6380
q12 2.3308
q13 2.6227
q14 2.3591
q15 2.7282
q16 0.5409
q17 2.4587
q18 3.0535
q19 2.8955
q20 3.5231
q21 4.1316
q22 0.7383
Total 58.2130