Skip to content

Add vortex.variant_pack and read shredded paths without core storage - #11851

Open
robert3005 wants to merge 3 commits into
rk/variant-get-conversionfrom
rk/variant-pack
Open

robert3005 wants to merge 3 commits into
rk/variant-get-conversionfrom
rk/variant-pack

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

Stacked on #11850.

A Variant stored as separate columns has to be put back together from its core storage and its shredded child before variant_get can run, which reads the core storage even for a path that is shredded. As a scalar function, vortex.variant_pack lets variant_get reduce to a read of the shredded column when the pack says the core storage cannot hold the path. A third child carries the shredded struct's validity, so the struct can be stored without nulls and a scan can push field reads through it.

🤖 Generated with Claude Code

…storage

A Variant stored as separate columns is put back together from its core storage and its shredded child. With the pack as a scalar function, variant_get over it reduces to a read of the shredded column when the pack is complete, so the scan never reads the core storage for a shredded path.

Signed-off-by: Robert Kruszewski <github@robertk.io>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Posted by Claude Opus 5.5 on Will's behalf.

The reduce rules look sound to me. A field that was not shredded is read from core. Reading the shredded child requires complete. After that, a nested shredded Variant gets the rest of the path, and a leaf of the requested type becomes a cast. Two points inline. The first is the one that matters.


/// Reads a shredded path from the shredded child of a [`VariantPack`] input, leaving its
/// core storage unread.
fn reduce<T: ReduceNode>(&self, options: &Self::Options, node: &T) -> VortexResult<Option<T>> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This rewrite decides which column a scan reads, so a wrong branch returns wrong values without an error. The PR has one test, and it covers the case where nothing is rewritten: the root struct with a validity child. Please add rstest cases that compare the reduced expression with the unreduced one over the same data, one for each branch:

  • a shredded field when complete is set;
  • the same field when complete is not set, which must not reduce;
  • a field that is not shredded, which reads core;
  • a path that ends in a nested shredded Variant;
  • a leaf of another type than the requested one.

It would also help to make core an array that fails when executed in the complete case, so that the test proves core is not read.

/// # Errors
///
/// Returns an error if `core` is not Variant data or the two differ in length.
pub fn try_new(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

try_new takes VariantPackOptions, so a caller can pass with_shredded_validity(..) with two children and get an arity error at run time. The variant_pack expression helper takes complete: bool. Taking complete: bool here too would make the two constructors match and remove that misuse.

Each reduce rule is checked against the Variant that the pack builds, and against which child the reduced array reads. VariantPack::try_new takes complete as the variant_pack expression does, so it cannot be given options that need a validity child.

Signed-off-by: Robert Kruszewski <github@robertk.io>

@lwwmanning lwwmanning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Posted by Claude Opus 5.5 on Will's behalf.

Both comments are resolved. The new rstest cases cover each reduce branch. They check which child the reduced expression reads, finding the arrays of core by pointer so a read of core cannot go unseen, and compare the result with the unreduced extraction. try_new now takes complete. No further findings.

@codspeed

codspeed Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Merging this PR will improve performance by 12.54%

2 warnings

⚠️ Walltime results may be unreliable

Some benchmarks used the Walltime instrument outside CodSpeed Macro Runners, which can make the results inconsistent.

Learn more about Macro Runners

See affected benchmarks

⚠️ 2 benchmarks are dominated by system calls

System calls cannot be simulated consistently and are left out of the measure. The reported value understates the real cost. Switch to the Walltime instrument to measure them.

Learn more about system calls

See affected benchmarks

⚡ 2 improved benchmarks
✅ 2028 untouched benchmarks
⏩ 136 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
⚡ CPU Simulation filter_random_by_correlated_runs[100000] 66.7 µs 58.1 µs +14.73%
⚡ Walltime decode_avx512[DeltaU8] 11.1 µs 10 µs +10.4%

Tip

Curious why performance improved? Comment @codspeedbot explain why performance improved on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/variant-pack (497a004) with rk/variant-get-conversion (c302195)

Open in CodSpeed

Footnotes

  1. 136 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Will Manning <will@spiraldb.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/feature A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants