Skip to content

feat(array): add scalar probes with lazy child contexts - #9843

Open
joseph-isaacs wants to merge 2 commits into
developfrom
ji/array-probe-api
Open

feat(array): add scalar probes with lazy child contexts#9843
joseph-isaacs wants to merge 2 commits into
developfrom
ji/array-probe-api

Conversation

@joseph-isaacs

@joseph-isaacs joseph-isaacs commented Sep 11, 2026

Copy link
Copy Markdown
Contributor

Adds a probe API for repeated scalar_at

  // One-off lookup without retained preparation.
  let value = array.probe(ProbeUsage::Once).scalar_at(10, &mut ctx)?;

  // Repeated lookups share preparation until the probe is dropped.
  let mut probe = array.probe(ProbeUsage::Repeated);
  let first = probe.scalar_at(10, &mut ctx)?;
  let second = probe.scalar_at(20, &mut ctx)?;

Adds an encoding vtable.

pub trait OperationsVTable<V: VTable> {
    type ProbeState<'a>: Default + 'a;

    fn probe_scalar<'a>(
        array: ArrayView<'a, V>,
        index: usize,
        _probe: ProbeAccess<'a, '_, Self::ProbeState<'a>>,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<Scalar> {
        array.array().execute_scalar(index, ctx)
    }

    // Existing scalar hook.
    fn scalar_at(
        array: ArrayView<'_, V>,
        index: usize,
        ctx: &mut ExecutionCtx,
    ) -> VortexResult<Scalar>;
}

Encodings without preparation use ProbeState<'a> = () and the default hook. Overrides receive ProbeAccess::Once(array) or Repeated(state). Child reads use probe.slot(slot)?.execute_scalar(index, ctx)?, preserving preparation recursively.

The encoding implementations are in #9844. For PCO, assuming both indices fall in the same decoded page, that follow-up enables:

array.execute_scalar(10, &mut ctx)?; // Decodes for this lookup.
array.execute_scalar(20, &mut ctx)?; // Decodes again.
let mut probe = array.probe(ProbeUsage::Repeated);
probe.scalar_at(10, &mut ctx)?;      // Decodes and retains the page.
probe.scalar_at(20, &mut ctx)?;      // Reads from the retained page.

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
@joseph-isaacs joseph-isaacs added the changelog/break A breaking API change label Sep 11, 2026
@codspeed-hq

codspeed-hq Bot commented Sep 11, 2026

Copy link
Copy Markdown

Merging this PR will regress 3 benchmarks

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

⚡ 12 improved benchmarks
❌ 3 regressed benchmarks
✅ 2182 untouched benchmarks
⏩ 218 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
WallTime arrow_checked_add_u32_neon[16384] 12.3 µs 20.3 µs -39.69%
Simulation random_i16[0.95] 80.3 µs 99.5 µs -19.27%
WallTime words_gather_scalar_avx2[1024] 147 ns 165 ns -10.91%
WallTime mul_u64_nonnull_neon 21 µs 15.2 µs +37.95%
Simulation random_i8[0.5] 94.7 µs 71.8 µs +31.84%
WallTime filtered_sink_i64_avx512[NineNullsInTen] 17.2 µs 13.9 µs +23.67%
WallTime filtered_sink_i64_avx2[OneNullInEight] 31.1 µs 25.4 µs +22.38%
WallTime filtered_sink_i64_avx2[NineNullsInTen] 16.2 µs 13.4 µs +20.7%
WallTime filtered_sink_i64_avx512[OneNullInEight] 31.8 µs 26.6 µs +19.33%
WallTime mul_i64_nonnull_neon 20.2 µs 17.1 µs +18.22%
WallTime multiply_shapes_neon[(16384, PerRowPerRow)] 20.2 µs 17.1 µs +17.72%
WallTime filtered_owned_i64_avx2[OneNullInEight] 25.8 µs 22.1 µs +16.88%
WallTime dict_canonicalize_gt_u8_neon[1000000] 560.2 µs 487.4 µs +14.95%
WallTime words_gather_scalar_avx2[65536] 9.4 µs 8.2 µs +13.54%
Simulation allocate_drop_arrow[0] 456.9 ns 402.7 ns +13.45%

Tip

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


Comparing ji/array-probe-api (9ca43c4) with develop (8f3dfb4)

Open in CodSpeed

Footnotes

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

Replace inline type-erased storage with a lazy boxed implementation and
leave a FIXME to revisit inline storage only if benchmarks justify it.

Signed-off-by: Joe Isaacs <joe.isaacs@live.co.uk>
@joseph-isaacs
joseph-isaacs marked this pull request as ready for review September 14, 2026 14:04
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