Skip to content

Build arrays through non-generic constructors - #10737

Open
robert3005 wants to merge 1 commit into
developfrom
rk/size-nongeneric-array-ctors
Open

robert3005 wants to merge 1 commit into
developfrom
rk/size-nongeneric-array-ctors

Conversation

@robert3005

@robert3005 robert3005 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

The generic constructors (ConstantArray::new<S>, PrimitiveArray::{new, try_new, new_unchecked, empty}<T>, DecimalArray::{try_new, new_unchecked}<T>, and the impl IntoIterator constructors of StructArray and ChunkedArray) called the generic Array::from_parts_unchecked and Array::try_from_parts directly. Each crate that called them monomorphized its own copy of those functions and of the full DynArrayData vtable for the encoding.

The generic constructors now call a private, non-generic builder. vortex-array compiles each vtable once, and other crates call it. ScalarFn had the same problem because new_from_validated_slots was #[inline], and it is not inlined now. The cost is one function call when an array is constructed.

vortex-ffi release cdylib (macOS arm64) before after
__text 37,223,740 B 36,613,308 B (-610 KB)
Copies of the vtable: Constant / Primitive / Struct / Chunked / Decimal / ScalarFn 22 / 17 / 7 / 5 / 5 / 4 1 / 1 / 1 / 1 / 1 / 1

@robert3005 robert3005 added the changelog/chore A trivial change label Oct 23, 2026
The generic constructors of Constant, Primitive, Struct, Chunked and
Decimal arrays called the generic Array::from_parts_unchecked and
Array::try_from_parts directly. Each crate that called them compiled
its own copy of the from_parts functions and of the full DynArrayData
vtable for the encoding. The generic constructors now call a private
non-generic function, so vortex-array compiles each vtable once.
ScalarFn had the same problem because new_from_validated_slots was
#[inline]; it is not inlined now.

vortex-ffi release cdylib __text: 37,223,740 -> 36,613,308 bytes
(-610 KB). Copies of the Constant vtable: 22 -> 1, Primitive: 17 -> 1.

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005
robert3005 force-pushed the rk/size-nongeneric-array-ctors branch from 2193919 to 6b24a64 Compare October 23, 2026 17:01
@codspeed

codspeed Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Merging this PR will degrade performance by 11.41%

4 warnings, 1 note

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

⚠️ Unable to measure the execution of 1 benchmark

This benchmark measured no execution time, so its result is not comparable and counts as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

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

⚠️ Base and head ran on different runner types

Some benchmarks with significant performance changes were compared across different runner types, so the changes might not come from the code. Run base and head on the same runner type, or use CodSpeed Macro Runners for more stable results.

Learn more about Macro Runners

Open the report in CodSpeed to investigate

ℹ️ 40 benchmarks have no flamegraph

The flamegraph wasn't generated: the symbols of the profiling trace could not be resolved, because no information about the language frames was collected.

See affected benchmarks

⚡ 6 improved benchmarks
❌ 7 regressed benchmarks
✅ 2395 untouched benchmarks
⏩ 12 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ Walltime threshold_neon[8] 1.3 µs 2.5 µs -47.79%
❌ Walltime filter_neon[64] 1.8 µs 3 µs -40.63%
❌ Walltime filter_neon[8] 940 ns 1,569 ns -40.09%
❌ Walltime threshold_neon[80] 3.4 µs 4.4 µs -21.68%
❌ Walltime threshold_neon[64] 2.5 µs 3.2 µs -20.35%
❌ CPU Simulation new_bp_prim_test_between[i16, 2048] 57.6 µs 71.7 µs -19.65%
❌ Walltime filter_neon[80] 2.6 µs 3.3 µs -19.02%
⚡ CPU Simulation new_raw_prim_test_between[i32, 2048] 81.5 µs 58.9 µs +38.33%
⚡ CPU Simulation random_i128[0.01] 5.8 µs 4.7 µs +22.5%
⚡ CPU Simulation test_scan_filter_to_arrow_array[int_float] 4.1 ms 3.5 ms +15.99%
⚡ CPU Simulation test_repeated_scan_filter[int_float] 3.9 ms 3.4 ms +12.5%
⚡ CPU Simulation test_repeated_scan_filter[int] 2.7 ms 2.4 ms +11.71%
⚡ CPU Simulation test_scan_filter_to_arrow_array[int] 2.8 ms 2.5 ms +11.12%

Tip

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


Comparing rk/size-nongeneric-array-ctors (6b24a64) with develop (8c680f2)2

Open in CodSpeed

Footnotes

  1. 12 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. ↩

  2. No successful run was found on develop (c88edde) during the generation of this report, so 8c680f2 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

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/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant