Skip to content

Optimise Patches::filter to better handle sparse masks and sparse patches - #10149

Open
robert3005 wants to merge 1 commit into
developfrom
rk/patchesfilter
Open

robert3005 wants to merge 1 commit into
developfrom
rk/patchesfilter

Conversation

@robert3005

Copy link
Copy Markdown
Contributor

We assumed dense case of mask over patches. Most of the time the mask or the
patches will be sparse

@codspeed

codspeed Bot commented Sep 30, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 8.03%

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

⚡ 2 improved benchmarks
❌ 3 regressed benchmarks
✅ 2057 untouched benchmarks
⏩ 503 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
❌ WallTime mul_u64_nonnull_neon 29.6 µs 40.1 µs -26.2%
❌ WallTime multiply_shapes_neon[(32768, PerRowPerRow)] 33.3 µs 39.1 µs -15.02%
❌ WallTime mul_i64_nonnull_neon 33.5 µs 39.1 µs -14.52%
⚡ WallTime dict_canonicalize_gt_u8_neon[1000000] 547 µs 493.4 µs +10.86%
⚡ WallTime scalar_subtract_neon 13.9 µs 12.6 µs +10.73%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/patchesfilter (1d66d12) with develop (a96e0a8)

Open in CodSpeed

Footnotes

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

@robert3005 robert3005 added the changelog/performance A performance improvement label Sep 30, 2026
@robert3005
robert3005 marked this pull request as ready for review September 30, 2026 05:45
Comment on lines +1216 to +1235
/// The search compares values in the patch index type, so the patches do not need conversion.
struct PatchGallop<'a, T> {
patch_indices: &'a [T],
offset: usize,
patch_position: usize,
mask_position: usize,
new_patch_indices: &'a mut BufferMut<u64>,
kept_patches: &'a mut Vec<usize>,
}

impl<T: IntegerPType> PatchGallop<'_, T> {
fn next_mask_index(&mut self, mask_index: usize) -> Result<(), NoMoreMatches> {
// Mask indices are sorted, so no later mask index fits in `T` either.
let needle = mask_index
.checked_add(self.offset)
.and_then(<T as NumCast>::from)
.ok_or(NoMoreMatches)?;

self.patch_position = gallop_lower_bound(self.patch_indices, self.patch_position, &needle);
if self.patch_position == self.patch_indices.len() {

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.

this is odd?

This branch has not been deployed

No deployments
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.

2 participants