Skip to content

Build arrays through non-generic constructors - #10737

Merged
connortsui20 merged 1 commit into
developfrom
rk/size-nongeneric-array-ctors
Oct 26, 2026
Merged

connortsui20 merged 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
@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 5.18%

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 2 benchmarks

These benchmarks measured no execution time, so their results are not comparable and count as unchanged. This usually happens when the compiler removes the code under test.

Prevent compiler optimizations

See affected benchmarks

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

⚡ 7 improved benchmarks
❌ 4 regressed benchmarks
✅ 2428 untouched benchmarks
⏩ 12 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ CPU Simulation bench_compare_sliced_dict_primitive[(3333, 10000)] 32.9 µs 72.8 µs -54.72%
❌ Walltime mul_u64_nonnull_neon 20.6 µs 39.1 µs -47.43%
❌ CPU Simulation filter_powerlaw_by_random[250000] 131.3 µs 175.3 µs -25.11%
❌ CPU Simulation new_bp_prim_test_between[i16, 2048] 53.6 µs 68.1 µs -21.33%
⚡ CPU Simulation new_raw_prim_test_between[i32, 2048] 76.2 µs 53.5 µs +42.48%
⚡ CPU Simulation chunked_dict_primitive_canonical_into[f64, (1000, 1000, 10)] 203.3 µs 147.2 µs +38.05%
⚡ CPU Simulation compare[1] 124.3 µs 102.7 µs +21.03%
⚡ CPU Simulation missing_stats[16] 83.4 µs 69.4 µs +20.14%
⚡ CPU Simulation decompress[u16, (4000, 256)] 62.5 µs 55.2 µs +13.29%
⚡ Walltime add_constant_shapes_neon[(32768, ConstantPerRow)] 15.8 µs 14.3 µs +10.98%
⚡ Walltime add_constant_shapes_neon[(32768, PerRowConstant)] 15.8 µs 14.3 µs +10.45%

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 (b68f68b) with develop (76d8371)

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

@connortsui20
connortsui20 enabled auto-merge (squash) October 26, 2026 16:07
@connortsui20
connortsui20 force-pushed the rk/size-nongeneric-array-ctors branch from 6b24a64 to 984a878 Compare October 26, 2026 16:07
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 <github@robertk.io>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@robert3005
robert3005 force-pushed the rk/size-nongeneric-array-ctors branch from 984a878 to b68f68b Compare October 26, 2026 16:20
@connortsui20
connortsui20 merged commit ffaec9f into develop Oct 26, 2026
79 of 81 checks passed
@connortsui20
connortsui20 deleted the rk/size-nongeneric-array-ctors branch October 26, 2026 16:30
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.

2 participants