Repository navigation
perf(query): a GRAPH scope's columns leave as they are when nothing decodes - #2453
Merged
Merged
Conversation
…ecodes A GRAPH block hands its rows back through `ScopeCrossing::leave`, which decodes only when the outer context can't read the scope's store. Since `leave` became fallible, every binding of every scope column went through it and a `collect::<Result<..>>` adapter, even when both sides read one store and nothing could change. That is the common case, and it cost a GRAPH block over one ledger about 0.5% more instructions than before. `leave_column` clones such a column outright, as `enter_batch` already does on the way in, and decodes the others with `try_collect_vec`. Both `GraphOperator` paths (batched, and per parent row) use it.
Pins both sides of `leave_column`: with no decoder a column (or rows of it) comes back as it is; with one, an encoded binding still goes through it and fails over an empty store instead of leaving encoded.
bplatz
approved these changes
Nov 19, 2026
bplatz
left a comment
Contributor
There was a problem hiding this comment.
Approving. Please review the inline comments before merging.
… decodes The batched GRAPH path built its output by copying every column of the inner batch, which it owns and drops right after: the parent columns with `to_vec`, and the scope's own through `leave_column`, which clones when nothing decodes. When nothing decodes and the batch holds every column of the scope's schema, `ScopeCrossing::leave_batch` now hands the batch to `project_owned`, which moves the columns and drops the rest; otherwise it builds the columns as before.
bplatz
added a commit
that referenced
this pull request
Nov 21, 2026
Brings #2453 (a GRAPH scope's columns leave as they are when nothing decodes), #2455 (a governed graph source honors its model's override control), #2467 (R2RML scan join emit; iceberg top-k read budget) and #2468 (vector identity follow-up: the whole-graph distinct-object count counts vectors by value, a cold identity-table build fetches its arena in one round, and the build stops on cancellation). Conflicts: - fast_count.rs: main's vector count on next's lead walk. count_distinct_lead_groups_inner tallies vector-only leaflets apart from the rest, and the NumBig liveness helpers take an ArenaRange (a store's NumBig o_types, or the vector o_type alone), so they serve count_distinct_vector_objects as main's generalized helpers do. count_distinct_objects_for_predicate takes next's tracker and main's cancellation, as do its callers in fast_predicate_scalar_agg.rs and fast_whole_graph_agg.rs. - fast_group_count_firsts.rs: next's pooled-graph guard with main's answer_or_decline. - o_type.rs: next's NumBig wording plus main's paragraph on arena contents. - fluree_ext.rs: next's SourcePolicy and model-instance check, with main's async config and the model's override control. - core lib.rs: main's MemoryCharge re-export; annotation_index has no home on next. - Cargo.toml, regression-budget.json: both benches. Ports: - vector.rs: register_missing asks ContentStore::get_local whether a shard is resident; next has no resolve_cached_bytes, and a shard's cid is not optional. - Tests: the residency vector arena stores its shards through write_test_shard_in, and BinaryIndexStore::empty() takes no directory.
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.
A
GRAPHblock got about 0.5% more expensive when #2214 landed, and this gives it back.GraphOperator::next_streamedhands each scope column back throughScopeCrossing::leave, which decodes a binding only when the outer context can't read the scope's store (a cross-ledger body, say). #2214 madeleavefallible, so every binding of every scope column started going through it and acollect::<Result<..>>adapter (GenericShunt, which stays out of line per item). That happens even in the common case, where both sides read one store, the crossing has no decoder, andleavehands the binding back untouched.So
ScopeCrossinggetsleaves_unchanged()andleave_column(). A column that leaves unchanged is cloned outright, the wayenter_batchalready short-circuits on the way in. In the batched path, where the scope owns the inner batch, the columns are moved out of it instead (ScopeCrossing::leave_batch, from review). Otherwise each binding still goes throughleave, viatry_collect_vec, the plain loop we use on the other per-row key paths. BothGraphOperatorpaths (batched, and per parent row) use it. The thirdleavesite, SERVICE's row merge, pushes with?per binding and has no adapter, so I left it alone.Numbers
Single-thread
instructions:u, per query, on a quietc7i.8xlarge, fat-LTO release builds, 6 interleaved reps each. The shape isSELECT ?s ?n WHERE { GRAPH <urn:g1> { ?s ex:name ?n } }over 5,000 subjects.b38268f33mainbefore #2214:fe5febcb9/4adc62e89/f42ea3784/b38268f3388c3cf134(#2214's merge)main0824793ba0824793baSo that's −0.73% against
main. The threemains right before #2214 agree within 0.06%, and both after it sit at +0.5%, so the step is #2214's, not layout. In the profile, theGenericShuntand per-bindingleavesamples (1.2% ofmain's) are gone, replaced byleave_column's clone loop at 0.27%. The controls are flat: the subject probe at +0.01%, the count plan at 0.00% and the object probe at −0.05%. The subject probe's own +0.22% at #2214 sat inside the spread of the earliermains, and today'smainruns it 1.5% under them (I'd guess #2404's leaf skip), so there was nothing to fix there.Tests
a_column_leaves_unchanged_only_when_nothing_decodespins both sides. With no decoder, a column (whole or by rows) comes back as it is. With one, an encoded binding still goes through it, and over an empty store it fails rather than leaving encoded. Withleave_columnforced onto the clone path, the test fails.fluree-db-query's unit tests, plusgrp_query,grp_graphsource(the cross-ledgerGRAPHand SERVICE scopes) andit_multigraph_lanes, all pass. Clippy and fmt are clean.