Skip to content

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

Open
mhk197 wants to merge 4 commits into
developfrom
mk/for-global-reference
Open

mhk197 wants to merge 4 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 regress 1 benchmark

⚠️ 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.

⚠️ 17 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

⚡ 2 improved benchmarks
❌ 1 regressed benchmark
✅ 2210 untouched benchmarks
🗄️ 43 archived benchmarks run1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Simulation decode_primitives[i64, (1000, 32)] 24.7 µs 38.3 µs -35.54%
⚡ ⚠️ Simulation density_sweep_dense_runs[0.001] 47.9 µs 29.9 µs +60.28%
⚡ ⚠️ Simulation filter_powerlaw_by_mostly_true[250000] 150.5 µs 104.1 µs +44.62%

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 (6e089e9) with develop (fdba755)

Open in CodSpeed

Footnotes

  1. 43 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

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/break A breaking API change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant