Skip to content

unsafe Scalar::struct_unchecked in scalar_at vtable#6741

Open
palaska wants to merge 6 commits intodevelopfrom
bp/scalar_at
Open

unsafe Scalar::struct_unchecked in scalar_at vtable#6741
palaska wants to merge 6 commits intodevelopfrom
bp/scalar_at

Conversation

@palaska
Copy link
Contributor

@palaska palaska commented Mar 2, 2026

Scalar::struct_ collects field scalars into a Vec<Scalar> before dtype-checking them, then collects again into the final value list — two allocations per row.

Add Scalar::struct_unchecked (accepts impl IntoIterator) that skips the checks and does a single allocation. The StructVTable::scalar_at vtable already guarantees index is in-bounds and non-null, and each field's scalar_at returns the correct dtype, so the unchecked path is safe there.

Signed-off-by: Baris Palaska <barispalaska@gmail.com>
@palaska palaska added the changelog/performance A performance improvement label Mar 2, 2026
@palaska palaska requested a review from joseph-isaacs March 2, 2026 13:50
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 2, 2026

Merging this PR will improve performance by 18%

⚡ 2 improved benchmarks
✅ 952 untouched benchmarks
⏩ 1466 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation scalar_at_struct_simple 815 µs 690.7 µs +18%
Simulation scalar_at_struct_wide 3.6 ms 3.1 ms +15.45%

Comparing bp/scalar_at (9629bea) with develop (e760519)

Open in CodSpeed

Footnotes

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

palaska added 2 commits March 2, 2026 14:16
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
@palaska palaska requested a review from joseph-isaacs March 2, 2026 14:52
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
@palaska palaska changed the title Add scalar_at_fields to avoid Vec allocation when iterating field scalars unsafe Scalar::struct_unchecked in scalar_at vtable Mar 2, 2026
palaska added 2 commits March 2, 2026 16:54
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
Signed-off-by: Baris Palaska <barispalaska@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/performance A performance improvement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants