Repository navigation
perf: optimize get_field - #23537
perf: optimize get_field#23537andygrove merged 2 commits into
get_field#23537Conversation
get_field
| .enumerate() | ||
| .find(|(_, t)| t.unwrap()); | ||
| let matched = (start..end).find(|&i| { | ||
| matches.value(i) && match_nulls.is_none_or(|nulls| nulls.is_valid(i)) |
There was a problem hiding this comment.
the previous logic always unwrapped, meaning it ignored any nulls; i assume this is to do with how map array keys cannot be null. perhaps we can follow on that assumption and ignore null check as before?
There was a problem hiding this comment.
Good call — map keys are non-null by definition, so the comparison result never carries nulls here. Dropped the check to match the previous behavior (which unwrapped unconditionally). Done in c4ed51d.
Map keys are non-null by definition, so the comparison result carries no nulls to check while scanning for a match.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #23537 +/- ##
=======================================
Coverage ? 80.67%
=======================================
Files ? 1086
Lines ? 366795
Branches ? 366795
=======================================
Hits ? 295902
Misses ? 53262
Partials ? 17631 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
Thanks for the review @Jefffrey |
## Which issue does this PR close?
N/A
## Rationale for this change
Optimize existing function.
## What changes are included in this PR?
Removed the per-row `BooleanArray::slice` allocation in map key lookup
by scanning the key-comparison bitmap in place over each row's offset
range.
## Are these changes tested?
Existing tests.
Benchmark (criterion):
- get_field_map_1024_entries_16_last: 6.23% faster (base 42011ns -> cand
39394ns)
- get_field_map_1024_entries_4_missing: 12.267% faster (base 19070ns ->
cand 16730ns)
- get_field_map_8192_entries_4_last: 8.122% faster (base 168450ns ->
cand 154769ns)
- get_field_map_1024_entries_4_last: 11.166% faster (base 23229ns ->
cand 20635ns)
- get_field_map_1024_entries_4_first: 15.396% faster (base 20877ns ->
cand 17663ns)
Full criterion output:
```text
get_field_map_1024_entries_4_first
time: [17.664 µs 17.701 µs 17.756 µs]
change: [−15.807% −15.396% −14.964%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
4 (4.00%) high mild
2 (2.00%) high severe
get_field_map_1024_entries_4_last
time: [20.450 µs 20.499 µs 20.546 µs]
change: [−11.535% −11.166% −10.793%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
2 (2.00%) low mild
4 (4.00%) high mild
get_field_map_1024_entries_16_last
time: [39.406 µs 39.460 µs 39.516 µs]
change: [−6.9089% −6.2297% −5.5570%] (p = 0.00 < 0.05)
Performance has improved.
Found 11 outliers among 100 measurements (11.00%)
6 (6.00%) low severe
2 (2.00%) high mild
3 (3.00%) high severe
get_field_map_1024_entries_4_missing
time: [16.755 µs 16.775 µs 16.796 µs]
change: [−12.675% −12.267% −11.888%] (p = 0.00 < 0.05)
Performance has improved.
Found 6 outliers among 100 measurements (6.00%)
4 (4.00%) high mild
2 (2.00%) high severe
get_field_map_8192_entries_4_last
time: [154.23 µs 154.92 µs 155.72 µs]
change: [−8.5962% −8.1217% −7.6240%] (p = 0.00 < 0.05)
Performance has improved.
Found 12 outliers among 100 measurements (12.00%)
11 (11.00%) high mild
1 (1.00%) high severe
```
## Are there any user-facing changes?
No
<!--
If there are user-facing changes then we may require documentation to be
updated before approving the PR.
-->
<!--
If there are any breaking changes to public APIs, please add the `api
change` label.
-->
Which issue does this PR close?
N/A
Rationale for this change
Optimize existing function.
What changes are included in this PR?
Removed the per-row
BooleanArray::sliceallocation in map key lookup by scanning the key-comparison bitmap in place over each row's offset range.Are these changes tested?
Existing tests.
Benchmark (criterion):
Full criterion output:
Are there any user-facing changes?
No