Skip to content

Sparse followup#6980

Merged
connortsui20 merged 1 commit intodevelopfrom
ct/cast-sparse
Mar 16, 2026
Merged

Sparse followup#6980
connortsui20 merged 1 commit intodevelopfrom
ct/cast-sparse

Conversation

@connortsui20
Copy link
Contributor

Summary

Followup to #6979

We should use the default value here to fast path the null, and also the comment was incorrect since casting can always fail.

Testing

N/A

Signed-off-by: Connor Tsui <connor.tsui20@gmail.com>
@connortsui20 connortsui20 added the changelog/fix A bug fix label Mar 16, 2026
@connortsui20 connortsui20 enabled auto-merge (squash) March 16, 2026 13:43
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 16, 2026

Merging this PR will improve performance by 18.36%

⚡ 2 improved benchmarks
✅ 1007 untouched benchmarks
⏩ 1515 skipped benchmarks1

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation bitwise_not_vortex_buffer_mut[1024] 535.6 ns 477.2 ns +12.22%
Simulation bitwise_not_vortex_buffer_mut[128] 376.1 ns 317.8 ns +18.36%

Comparing ct/cast-sparse (6b1e919) with develop (dbc1a24)

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.

@connortsui20 connortsui20 requested a review from robert3005 March 16, 2026 14:13
Comment on lines +22 to +28
let casted_fill = if array.patches().num_patches() == array.len() {
// When every position is patched the fill scalar is unused and can be undefined.
// We skip casting it entirely and substitute a default value for the target dtype.
Scalar::default_value(dtype)
} else {
array.fill_scalar().cast(dtype)?
};
Copy link
Contributor

Choose a reason for hiding this comment

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

why move this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just following the order of the constructor, no other reason

Copy link
Contributor

Choose a reason for hiding this comment

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

okay, also why default vs zero?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if the type is nested it could be expensive (allocations).

Versus just creating a null scalar which is cheap.

@connortsui20 connortsui20 merged commit bf5f390 into develop Mar 16, 2026
103 of 105 checks passed
@connortsui20 connortsui20 deleted the ct/cast-sparse branch March 16, 2026 14:38
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.

2 participants