Skip to content

fix[vortex-array]: fix overflow on FSL element take indices#7214

Merged
robert3005 merged 1 commit intodevelopfrom
asubiotto/fsltake
Mar 31, 2026
Merged

fix[vortex-array]: fix overflow on FSL element take indices#7214
robert3005 merged 1 commit intodevelopfrom
asubiotto/fsltake

Conversation

@asubiotto
Copy link
Copy Markdown
Contributor

The take index types used on an FSL might be valid narrow types. This type was used as indices to take the inner elements, which could result in an overflow with long enough lists.

Summary

Closes: #000

Testing

The take index types used on an FSL might be valid narrow types. This type was
used as indices to take the inner elements, which could result in an overflow
with long enough lists.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
@asubiotto asubiotto requested a review from connortsui20 March 31, 2026 14:19
@asubiotto asubiotto added the changelog/fix A bug fix label Mar 31, 2026
@asubiotto
Copy link
Copy Markdown
Contributor Author

We maybe could use usize for the element indices to avoid the generic type parameter

@codspeed-hq
Copy link
Copy Markdown

codspeed-hq bot commented Mar 31, 2026

Merging this PR will improve performance by 21.68%

⚡ 8 improved benchmarks
✅ 1098 untouched benchmarks
⏩ 1522 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation take_fsl_nullable_random[1024, 1000] 21.3 ms 17.5 ms +21.68%
Simulation take_fsl_nullable_random[64, 1000] 1.2 ms 1 ms +11.68%
Simulation take_fsl_nullable_random[4096, 1000] 89.5 ms 76.3 ms +17.38%
Simulation take_fsl_nullable_random[4096, 100] 7.9 ms 7.1 ms +10.42%
Simulation take_fsl_random[1024, 1000] 21.5 ms 18.1 ms +18.44%
Simulation take_fsl_random[16, 1000] 330.1 µs 299.9 µs +10.08%
Simulation take_fsl_random[64, 1000] 1.2 ms 1 ms +11.39%
Simulation take_fsl_random[4096, 1000] 90.7 ms 79 ms +14.72%

Comparing asubiotto/fsltake (3ac0e81) with develop (60aba91)

Open in CodSpeed

Footnotes

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

Validity::from_iter([true, true, false]), 3,
),
)]
fn test_element_index_overflow(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I tried running this on develop and it did not fail, is there something else that happens here?

@connortsui20
Copy link
Copy Markdown
Contributor

seems like there is a nice perf gain from this, so might as well do this?

@robert3005 robert3005 merged commit df84cee into develop Mar 31, 2026
69 of 70 checks passed
@robert3005 robert3005 deleted the asubiotto/fsltake branch March 31, 2026 18:09
@connortsui20
Copy link
Copy Markdown
Contributor

um... do we want to write a regression test that actually fails?

@robert3005
Copy link
Copy Markdown
Contributor

We have it. I already merged a change to the macro that exposes the bug

@asubiotto
Copy link
Copy Markdown
Contributor Author

Yeah, sorry it got lost in the rstest parameterization. The take was lazily wrapping the fsl in a dictionary

asubiotto added a commit that referenced this pull request Mar 31, 2026
The elements were incorrectly refactored by claude when I got it to clean up
and parameterize tests.
Additionally, this adds a to_fixed_size_list to the take so it actually gets
executed and would fail without #7214.

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
@asubiotto
Copy link
Copy Markdown
Contributor Author

Still couldn't get it to fail without a to_fixed_size_list. Here's a PR with the test changes: #7229

asubiotto added a commit that referenced this pull request Mar 31, 2026
The elements were incorrectly refactored by claude when I got it to
clean up and parameterize tests.
This commit actually makes the elements interesting.
Additionally, this adds a to_fixed_size_list to the take so it actually
gets executed and would fail without #7214.

<!--
Thank you for submitting a pull request! We appreciate your time and
effort.

Please make sure to provide enough information so that we can review
your pull
request. The Summary and Testing sections below contain guidance on what
to
include.
-->

## Summary

<!--
If this PR is related to a tracked effort, please link to the relevant
issue
here (e.g., `Closes: #123`). Otherwise, feel free to ignore / delete
this.

In this section, please:

1. Explain the rationale for this change.
2. Summarize the changes included in this PR.

A general rule of thumb is that larger PRs should have larger summaries.
If
there are a lot of changes, please help us review the code by explaining
what
was changed and why.

If there is an issue or discussion attached, there is no need to
duplicate all
the details, but clarity is always preferred over brevity.
-->

Closes: #000

<!--
## API Changes

Uncomment this section if there are any user-facing changes.

Consider whether the change affects users in one of the following ways:

1. Breaks public APIs in some way.
2. Changes the underlying behavior of one of the engine integrations.
3. Should some documentation be updated to reflect this change?

If a public API is changed in a breaking manner, make sure to add the
appropriate label. You can run `./scripts/public-api.sh` locally to see
if there
are any public API changes (and this also runs in our CI).
-->

## Testing

<!--
Please describe how this change was tested. Here are some common
categories for
testing in Vortex:

1. Verifying existing behavior is maintained.
2. Verifying new behavior and functionality works correctly.
3. Serialization compatibility (backwards and forwards) should be
maintained or
   explicitly broken.
-->

Signed-off-by: Alfonso Subiotto Marques <alfonso.subiotto@polarsignals.com>
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.

3 participants