Skip to content

Blocked FoR: store a global reference scalar as metadata rather than child - #10222

Merged
mhk197 merged 6 commits into
developfrom
mk/for-global-reference
Oct 14, 2026
Merged

mhk197 merged 6 commits into
developfrom
mk/for-global-reference

Conversation

@mhk197

@mhk197 mhk197 commented Oct 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A FoR array now has either a global reference, stored as a Scalar in FoRData, or blocked references, one per 1024-element chunk, stored in an optional blocked_references child. Previously, a single reference was a ConstantArray child, and constant_reference() recovered it by downcasting that child.

With the reference as metadata, nothing can turn a single-reference array into a different encoding by rewriting its child: casts, optimizer rewrites and compressor passes no longer see a child to rewrite. Kernels read the reference directly instead of downcasting and cloning, and no ConstantArray is allocated for slice, take, filter or try_new.

API

  • FoRData { offset, global_reference: Option<Scalar> }. The references slot is renamed to blocked_references: Option<ArrayRef>.

  • references() returns the new FoRReferences enum, which replaces constant_reference():

    pub enum FoRReferences<'a> {
        Global(&'a Scalar),
        Blocked(&'a ArrayRef),
    }
  • validate requires exactly one of the two, and offset == 0 with a global reference.

  • FoR::try_new(encoded, reference) builds a global reference. FoR::try_new_chunked(encoded, references, offset) builds blocked references, except that a ConstantArray of references becomes a global reference.

  • FoR::encode_chunked emits a global reference when every chunk has the same minimum. Previously those references stayed a PrimitiveArray, unless the compressor's constant detection, which only keeps a constant when it is smaller, happened to convert them.

@mhk197
mhk197 force-pushed the mk/for-global-reference branch from 99a8071 to 854f1a1 Compare October 12, 2026 20:22
@mhk197 mhk197 added the changelog/break A breaking API change label Oct 12, 2026
Comment thread encodings/fastlanes/src/for_/array/mod.rs Outdated
@mhk197
mhk197 requested a review from joseph-isaacs October 12, 2026 20:46
@mhk197
mhk197 marked this pull request as ready for review October 12, 2026 20:46
@mhk197
mhk197 requested a review from robert3005 October 12, 2026 20:55
@codspeed

codspeed Bot commented Oct 12, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 31.27%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ 10 benchmarks spent significant time in system calls

System calls cannot be consistently instrumented, so they are not included in the measure, which understates the real cost. Please switch to the Walltime instrument to accurately measure system calls.

Measurement and system calls

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 8 regressed benchmarks
✅ 2211 untouched benchmarks
🗄️ 12 archived benchmarks run1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ WallTime filter_neon[8] 1.1 µs 2.3 µs -53.12%
❌ Simulation density_sweep_dense_runs[0.001] 28.7 µs 46.5 µs -38.3%
❌ WallTime threshold_neon[8] 2.8 µs 4.4 µs -37.04%
❌ WallTime filter_neon[80] 2.9 µs 4.1 µs -28.7%
❌ WallTime filter_neon[64] 2.8 µs 3.9 µs -27.03%
❌ WallTime threshold_neon[64] 4.2 µs 5.6 µs -25.19%
❌ WallTime threshold_neon[80] 4.6 µs 5.7 µs -20.39%
❌ WallTime decode_chunked_neon[i64, 524288] 13.1 µs 14.9 µs -11.76%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing mk/for-global-reference (28f7192) with develop (b085f29)

Open in CodSpeed

Footnotes

  1. 12 benchmarks were run, but are now archived. If they were deleted in another branch, consider rebasing to remove them from the report. Instead if they were added back, click here to restore them. ↩

@mhk197 mhk197 changed the title Store a single FoR reference as metadata Blocked FoR: store a global reference as metadata Oct 12, 2026
@mhk197 mhk197 changed the title Blocked FoR: store a global reference as metadata Blocked FoR: store a global reference scalar as metadata rather than child Oct 12, 2026
Comment on lines +237 to +238
global_reference: Option<&Scalar>,
blocked_references: Option<&ArrayRef>,

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.

enum ?

Comment on lines +376 to +377
.vortex_expect("for_new")
.into_array(),

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.

better error message

Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197
mhk197 force-pushed the mk/for-global-reference branch from d80d13f to 9597f63 Compare October 14, 2026 18:43
Signed-off-by: Matt Katz <mhkatz97@gmail.com>
@mhk197
mhk197 enabled auto-merge (squash) October 14, 2026 19:03
@mhk197
mhk197 merged commit 345317b into develop Oct 14, 2026
91 of 93 checks passed
@mhk197
mhk197 deleted the mk/for-global-reference branch October 14, 2026 19:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants