Skip to content

fix[vortex-array]: fix rebuild_trim_elements overflow#6995

Merged
connortsui20 merged 1 commit intodevelopfrom
asubiotto/lrebuild
Mar 17, 2026
Merged

fix[vortex-array]: fix rebuild_trim_elements overflow#6995
connortsui20 merged 1 commit intodevelopfrom
asubiotto/lrebuild

Conversation

@asubiotto
Copy link
Contributor

This commit just casts offsets and sizes to u64/i64 before summing for simplicitly. We could make the logic more complicated but not sure it's worth it.

Summary

Closes: #6973

Testing

Regression test added

This commit just casts offsets and sizes to u64/i64 before summing for
simplicitly. We could make the logic more complicated but not sure it's worth
it.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
@asubiotto asubiotto requested review from 0ax1 and connortsui20 March 17, 2026 13:16
@asubiotto asubiotto added the changelog/fix A bug fix label Mar 17, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 17, 2026

Merging this PR will improve performance by 11.12%

⚡ 1 improved benchmark
✅ 1008 untouched benchmarks
⏩ 1515 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation binary_search_std 582.8 ns 524.4 ns +11.12%

Comparing asubiotto/lrebuild (9a89372) with develop (876813b)

Open in CodSpeed

Footnotes

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

Copy link
Contributor

@connortsui20 connortsui20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is probably fine given we narrow these in the compressor anyways. If for some reason this is bad (it probably isn't) then we can just do the next size up.

@connortsui20 connortsui20 merged commit b921999 into develop Mar 17, 2026
55 of 56 checks passed
@connortsui20 connortsui20 deleted the asubiotto/lrebuild branch March 17, 2026 13:30
@asubiotto
Copy link
Contributor Author

This shouldn't be relevant for the offsets/sizes width. This code path essentially only computes the "end" offset which is cast to a usize below to slice the elements.

PType::I64
});
let offsets = self.offsets().cast(wide_dtype.clone())?;
let sizes = self.sizes().cast(wide_dtype)?;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For types smaller than 64bit this will unconditionally widen => allocate a new buffer + do an element-wise copy.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, this is what I mean by "we could make the logic more complicated". To avoid the unconditional widening we would probably have to attempt the sum and then fall back to widening to the next largest width.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah I see, I guess we can act on this in case it shows up in perf profiles.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Definitely! We're always profiling after all 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

vortex-array: rebuild_trim_elements overflows calculating end offset

3 participants