You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by "wumeibanfa (via GitHub)" <gi...@apache.org> on 2025/12/28 07:24:55 UTC
[PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
wumeibanfa opened a new pull request, #59426:
URL: https://github.com/apache/doris/pull/59426
### What problem does this PR solve?
Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics
### Release note
None
### Check List (For Author)
- Test <!-- At least one of them must be included. -->
- [ ] Regression test
- [x] Unit Test
- [ ] Manual test (add detailed scripts or steps below)
- [ ] No need to test or manual test. Explain why:
- [ ] This is a refactor/code format and no logic has been changed.
- [ ] Previous test can cover this change.
- [ ] No code files have been changed.
- [ ] Other reason <!-- Add your reason? -->
- Behavior changed:
- [x] No.
- [ ] Yes. <!-- Explain the behavior change -->
- Does this need documentation?
- [x] No.
- [ ] Yes. <!-- Add document PR link here. eg: https://github.com/apache/doris-website/pull/1214 -->
### Check List (For Reviewer who merge this PR)
- [ ] Confirm the release note
- [ ] Confirm test cases
- [ ] Confirm document
- [ ] Add branch pick label <!-- Add branch pick label that this PR should merge into -->
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "wumeibanfa (via GitHub)" <gi...@apache.org>.
wumeibanfa commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694531983
don't use simd
```text
Running ./be/output/lib/benchmark_test
Run on (16 X 200 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x16)
L1 Instruction 64 KiB (x16)
L2 Unified 512 KiB (x16)
L3 Unified 32768 KiB (x1)
Load Average: 0.00, 0.00, 0.12
---------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
---------------------------------------------------------------------------------------------------------------
BM_bytes32_mask_to_bits32_mask/32/repeats:5_mean 3.92 ns 3.92 ns 5 bytes_per_second=7.61044G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_median 3.91 ns 3.91 ns 5 bytes_per_second=7.6193G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_stddev 0.011 ns 0.011 ns 5 bytes_per_second=22.2868M/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_cv 0.29 % 0.29 % 5 bytes_per_second=0.29%
BM_bytes32_mask_to_bits32_mask/64/repeats:5_mean 7.86 ns 7.86 ns 5 bytes_per_second=7.58778G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_median 7.84 ns 7.84 ns 5 bytes_per_second=7.60375G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_stddev 0.038 ns 0.038 ns 5 bytes_per_second=36.9531M/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_cv 0.48 % 0.48 % 5 bytes_per_second=0.48%
BM_bytes32_mask_to_bits32_mask/256/repeats:5_mean 31.4 ns 31.4 ns 5 bytes_per_second=7.60191G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_median 31.3 ns 31.3 ns 5 bytes_per_second=7.61015G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_stddev 0.077 ns 0.077 ns 5 bytes_per_second=19.1616M/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_cv 0.25 % 0.25 % 5 bytes_per_second=0.25%
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_mean 125 ns 125 ns 5 bytes_per_second=7.61962G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_median 125 ns 125 ns 5 bytes_per_second=7.6198G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_stddev 0.008 ns 0.008 ns 5 bytes_per_second=481.167k/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_cv 0.01 % 0.01 % 5 bytes_per_second=0.01%
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "wumeibanfa (via GitHub)" <gi...@apache.org>.
wumeibanfa commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694532404
use simd + handle 32 byte one time
```
Running ./be/output/lib/benchmark_test
Run on (16 X 200 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x16)
L1 Instruction 64 KiB (x16)
L2 Unified 512 KiB (x16)
L3 Unified 32768 KiB (x1)
Load Average: 0.96, 1.81, 4.70
---------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
---------------------------------------------------------------------------------------------------------------
BM_bytes32_mask_to_bits32_mask/32/repeats:5_mean 1.09 ns 1.09 ns 5 bytes_per_second=27.3451G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_median 1.09 ns 1.09 ns 5 bytes_per_second=27.3452G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_stddev 0.000 ns 0.000 ns 5 bytes_per_second=2.48125M/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_cv 0.01 % 0.01 % 5 bytes_per_second=0.01%
BM_bytes32_mask_to_bits32_mask/64/repeats:5_mean 2.18 ns 2.18 ns 5 bytes_per_second=27.3575G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_median 2.18 ns 2.18 ns 5 bytes_per_second=27.3937G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_stddev 0.005 ns 0.005 ns 5 bytes_per_second=65.1549M/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_cv 0.23 % 0.23 % 5 bytes_per_second=0.23%
BM_bytes32_mask_to_bits32_mask/256/repeats:5_mean 8.67 ns 8.67 ns 5 bytes_per_second=27.5142G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_median 8.67 ns 8.66 ns 5 bytes_per_second=27.5161G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_stddev 0.001 ns 0.001 ns 5 bytes_per_second=4.84825M/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_cv 0.02 % 0.02 % 5 bytes_per_second=0.02%
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_mean 34.7 ns 34.7 ns 5 bytes_per_second=27.4944G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_median 34.7 ns 34.7 ns 5 bytes_per_second=27.4981G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_stddev 0.011 ns 0.011 ns 5 bytes_per_second=8.69048M/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_cv 0.03 % 0.03 % 5 bytes_per_second=0.03%
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "hello-stephen (via GitHub)" <gi...@apache.org>.
hello-stephen commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694669923
# BE Regression && UT Coverage Report
Increment line coverage `100% (0/0)` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/59426_d860fdfa2cd9ae99881222ad8502aa83759542ae_merge/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/59426_d860fdfa2cd9ae99881222ad8502aa83759542ae_merge/report/index.html)
| Category | Coverage |
|-------------------|--------------------|
| Function Coverage | 72.21% (25051/34694) |
| Line Coverage | 58.92% (263069/446490) |
| Region Coverage | 53.74% (218281/406174) |
| Branch Coverage | 55.36% (93831/169504) |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694580820
<details>
<summary>TPC-DS: <b>Total hot run time: 178933 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpcds-tools
TPC-DS sf100 test result on commit d860fdfa2cd9ae99881222ad8502aa83759542ae, data reload: false
query5 4346 582 464 464
query6 353 243 263 243
query7 4232 477 279 279
query8 309 271 253 253
query9 8769 2553 2514 2514
query10 515 378 349 349
query11 15524 14909 14727 14727
query12 175 119 118 118
query13 1273 497 393 393
query14 5503 3093 2744 2744
query14_1 2664 2608 2682 2608
query15 218 203 181 181
query16 815 472 435 435
query17 1161 714 609 609
query18 2452 454 389 389
query19 247 232 212 212
query20 123 118 120 118
query21 220 146 117 117
query22 3964 4119 3841 3841
query23 16703 16193 16167 16167
query23_1 16239 16174 16067 16067
query24 7390 1685 1233 1233
query24_1 1219 1213 1226 1213
query25 563 473 431 431
query26 1247 274 160 160
query27 2769 471 301 301
query28 4498 2132 2157 2132
query29 807 537 446 446
query30 309 250 215 215
query31 837 699 629 629
query32 78 80 66 66
query33 529 333 283 283
query34 890 903 541 541
query35 784 852 714 714
query36 868 913 825 825
query37 133 91 76 76
query38 2933 3107 2901 2901
query39 773 765 742 742
query39_1 726 704 691 691
query40 228 136 120 120
query41 65 64 64 64
query42 109 103 102 102
query43 442 432 399 399
query44 1340 735 739 735
query45 193 191 178 178
query46 875 970 610 610
query47 1693 1731 1636 1636
query48 312 326 248 248
query49 620 434 349 349
query50 661 300 215 215
query51 3813 3913 3754 3754
query52 104 106 98 98
query53 320 361 286 286
query54 306 262 246 246
query55 77 77 74 74
query56 296 304 292 292
query57 1191 1161 1093 1093
query58 285 253 279 253
query59 2390 2476 2400 2400
query60 317 313 293 293
query61 165 165 158 158
query62 733 763 648 648
query63 325 293 302 293
query64 5020 1309 1010 1010
query65 4069 3957 3937 3937
query66 1463 435 329 329
query67 15169 15176 14855 14855
query68 3500 1031 728 728
query69 493 348 307 307
query70 1067 967 952 952
query71 345 298 272 272
query72 6100 5012 5173 5012
query73 725 674 316 316
query74 8943 8977 8752 8752
query75 3204 3149 2815 2815
query76 3740 1133 741 741
query77 519 395 298 298
query78 9456 9396 8783 8783
query79 1082 873 601 601
query80 964 645 552 552
query81 524 266 238 238
query82 420 137 107 107
query83 267 250 251 250
query84 255 124 104 104
query85 913 512 480 480
query86 341 321 278 278
query87 3163 3184 3066 3066
query88 3269 2322 2314 2314
query89 470 429 387 387
query90 2031 184 160 160
query91 193 184 161 161
query92 73 70 65 65
query93 1055 889 558 558
query94 566 319 300 300
query95 598 392 314 314
query96 594 473 215 215
query97 2293 2317 2235 2235
query98 209 196 199 196
query99 1362 1357 1259 1259
Total cold run time: 254460 ms
Total hot run time: 178933 ms
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] closed pull request #59426: [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics
URL: https://github.com/apache/doris/pull/59426
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "wumeibanfa (via GitHub)" <gi...@apache.org>.
wumeibanfa commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694536456
run buildall
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "Thearas (via GitHub)" <gi...@apache.org>.
Thearas commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694530083
Thank you for your contribution to Apache Doris.
Don't know what should be done next? See [How to process your PR](https://cwiki.apache.org/confluence/display/DORIS/How+to+process+your+PR).
Please clearly describe your PR:
1. What problem was fixed (it's best to include specific error reporting information). How it was fixed.
2. Which behaviors were modified. What was the previous behavior, what is it now, why was it modified, and what possible impacts might there be.
3. What features were added. Why was this function added?
4. Which code was refactored and why was this part of the code refactored?
5. Which functions were optimized and what is the difference before and after the optimization?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "wumeibanfa (via GitHub)" <gi...@apache.org>.
wumeibanfa commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694532699
use simd + handle 16 byte one time
```text
Running ./be/output/lib/benchmark_test
Run on (16 X 200 MHz CPU s)
CPU Caches:
L1 Data 64 KiB (x16)
L1 Instruction 64 KiB (x16)
L2 Unified 512 KiB (x16)
L3 Unified 32768 KiB (x1)
Load Average: 1.46, 1.21, 3.47
---------------------------------------------------------------------------------------------------------------
Benchmark Time CPU Iterations UserCounters...
---------------------------------------------------------------------------------------------------------------
BM_bytes32_mask_to_bits32_mask/32/repeats:5_mean 2.77 ns 2.77 ns 5 bytes_per_second=10.7547G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_median 2.77 ns 2.77 ns 5 bytes_per_second=10.7616G/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_stddev 0.005 ns 0.005 ns 5 bytes_per_second=18.5077M/s
BM_bytes32_mask_to_bits32_mask/32/repeats:5_cv 0.17 % 0.17 % 5 bytes_per_second=0.17%
BM_bytes32_mask_to_bits32_mask/64/repeats:5_mean 5.54 ns 5.54 ns 5 bytes_per_second=10.7593G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_median 5.54 ns 5.54 ns 5 bytes_per_second=10.7676G/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_stddev 0.010 ns 0.010 ns 5 bytes_per_second=20.5456M/s
BM_bytes32_mask_to_bits32_mask/64/repeats:5_cv 0.19 % 0.19 % 5 bytes_per_second=0.19%
BM_bytes32_mask_to_bits32_mask/256/repeats:5_mean 22.2 ns 22.2 ns 5 bytes_per_second=10.7202G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_median 22.2 ns 22.2 ns 5 bytes_per_second=10.7226G/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_stddev 0.012 ns 0.012 ns 5 bytes_per_second=5.81638M/s
BM_bytes32_mask_to_bits32_mask/256/repeats:5_cv 0.05 % 0.05 % 5 bytes_per_second=0.05%
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_mean 88.8 ns 88.8 ns 5 bytes_per_second=10.7428G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_median 88.8 ns 88.8 ns 5 bytes_per_second=10.7441G/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_stddev 0.050 ns 0.051 ns 5 bytes_per_second=6.29135M/s
BM_bytes32_mask_to_bits32_mask/1024/repeats:5_cv 0.06 % 0.06 % 5 bytes_per_second=0.06%
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694598397
# BE UT Coverage Report
Increment line coverage ` ` :tada:
[Increment coverage report](http://coverage.selectdb-in.cc/coverage/d860fdfa2cd9ae99881222ad8502aa83759542ae_d860fdfa2cd9ae99881222ad8502aa83759542ae/increment_report/index.html)
[Complete coverage report](http://coverage.selectdb-in.cc/coverage/d860fdfa2cd9ae99881222ad8502aa83759542ae_d860fdfa2cd9ae99881222ad8502aa83759542ae/report/index.html)
| Category | Coverage |
|-------------------|--------------------|
| Function Coverage | 53.41% (18953/35489) |
| Line Coverage | 39.27% (175818/447682) |
| Region Coverage | 33.85% (136068/402009) |
| Branch Coverage | 34.78% (58756/168940) |
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-4823418716
We're closing this PR because it hasn't been updated in a while.
This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and feel free a maintainer to remove the Stale tag!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "wumeibanfa (via GitHub)" <gi...@apache.org>.
wumeibanfa commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694536117
# BM_bytes32_mask_to_bits32_mask Performance Evaluation
## Benchmark Results
### BM_bytes32_mask_to_bits32_mask
| Size (bytes) | Origin (ns) | SVE (ns) | Improvement |
|--------------|-------------|----------|-------------|
| 32 | 3.92 | 1.09 | +72.2% |
| 64 | 7.86 | 2.18 | +72.3% |
| 256 | 31.4 | 8.67 | +72.4% |
| 1024 | 125 | 34.7 | +72.2% |
> Improvement = (Origin − SVE) / Origin
---
## Throughput Comparison
- **Origin implementation**
~7.6 GB/s (stable across all sizes)
- **SVE implementation**
~27.4–27.5 GB/s (stable across all sizes)
This represents an **approximately 3.6× throughput increase** when using SVE.
## Summary
SVE optimization delivers a **substantial and consistent performance improvement** for `bytes32_mask_to_bits32_mask`:
- **~72% latency reduction**
- **~3.6× throughput increase**
---
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694583483
<details>
<summary>ClickBench: <b>Total hot run time: 27.1 s</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/clickbench-tools
ClickBench test result on commit d860fdfa2cd9ae99881222ad8502aa83759542ae, data reload: false
query1 0.05 0.04 0.04
query2 0.09 0.05 0.05
query3 0.26 0.09 0.08
query4 1.61 0.11 0.12
query5 0.27 0.25 0.26
query6 1.17 0.63 0.63
query7 0.03 0.03 0.03
query8 0.05 0.05 0.04
query9 0.58 0.51 0.51
query10 0.56 0.55 0.56
query11 0.16 0.11 0.10
query12 0.15 0.11 0.11
query13 0.61 0.60 0.61
query14 1.00 0.97 0.98
query15 0.82 0.80 0.81
query16 0.41 0.40 0.40
query17 1.03 1.00 1.05
query18 0.23 0.22 0.21
query19 1.97 1.75 1.75
query20 0.02 0.01 0.01
query21 15.45 0.30 0.14
query22 4.89 0.06 0.05
query23 16.04 0.27 0.11
query24 1.36 0.28 0.61
query25 0.11 0.09 0.07
query26 0.15 0.13 0.13
query27 0.05 0.06 0.07
query28 4.05 1.23 1.03
query29 12.64 3.96 3.14
query30 0.29 0.14 0.12
query31 2.82 0.63 0.38
query32 3.24 0.54 0.46
query33 2.98 3.00 2.99
query34 16.78 5.20 4.51
query35 4.55 4.56 4.54
query36 0.65 0.50 0.48
query37 0.11 0.07 0.06
query38 0.07 0.05 0.04
query39 0.04 0.04 0.03
query40 0.17 0.14 0.14
query41 0.10 0.03 0.03
query42 0.04 0.03 0.03
query43 0.04 0.04 0.04
Total cold run time: 97.69 s
Total hot run time: 27.1 s
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "Copilot (via GitHub)" <gi...@apache.org>.
Copilot commented on code in PR #59426:
URL: https://github.com/apache/doris/pull/59426#discussion_r2650135951
##########
be/src/util/simd/bits.h:
##########
@@ -81,6 +85,38 @@ inline uint32_t bytes32_mask_to_bits32_mask(const uint8_t* data) {
_mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 16)), zero16)))
<< 16) &
0xffff0000);
+#elif defined(__ARM_FEATURE_SVE)
+ /*
+ * Assume the input data is [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 1. Comparison produces a predicate mask: is_one = [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 2. Construct a new vector: masked = [1, 2, 4, 8, 16, 32, 64, 128,1, 2, 4, 8, 16, 32, 64, 128, 0 (repeated 16 times)].
+ * For each position, if the corresponding element in is_one is 1, take the value from the mask array (mask_arr); otherwise, take 0.
+ *
+ * 3. Rearorder the elements: res = [1, 1, 0, 0, 2, 2, 0, 0, 4, 4, 0, 0, ...], where the index mapping is: j = (i % 4) * 8 + (i / 4).
+ *
+ * 4. Perform a horizontal sum to obtain the final result:
+ * mask = sum_{i=0}^{7} ( res[i*4] + (res[i*4 + 1] << 8) + (res[i*4 + 2] << 16) + (res[i*4 + 3] << 24)).
+ * This works because we use svreinterpret_u32_u8, treating every group of four u8 elements as a single u32.
+ */
+ static constexpr uint8_t mask_arr[32] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4,
+ 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32,
+ 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
+ svbool_t pg = svwhilelt_b8(0, 32);
+ svuint8_t mask_vec = svld1_u8(pg, mask_arr);
+ svbool_t is_one = svcmpeq_n_u8(pg, svld1_u8(pg, data), 1);
+ svuint8_t masked = svsel_u8(is_one, mask_vec, svdup_u8(0));
+
+ // j = i % 4 * 8 + i / 4
Review Comment:
The inline comment "j = i % 4 * 8 + i / 4" lacks clarity on operator precedence. Consider adding parentheses for clarity: "j = (i % 4) * 8 + i / 4" to match the computation in the code.
```suggestion
// j = (i % 4) * 8 + i / 4
```
##########
be/benchmark/benchmark_bit_simd.hpp:
##########
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <benchmark/benchmark.h>
+#include <vector>
+#include <random>
+
+#include "util/simd/bits.h"
+
+namespace doris {
+
+static void create_test_data(std::vector<uint8_t> &data, size_t size) {
+ std::mt19937 rng(123);
+ for (int i = 0; i < size; ++i) {
+ data[i] = rng() & 1;
+ }
+}
+
+inline uint32_t bitmask_8(const uint8_t* data) {
+ static constexpr uint8_t mask_arr[16] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
+ svbool_t pg = svwhilelt_b8(0, 16);
+ svuint8_t mask_vec = svld1_u8(pg, mask_arr);
+
+ svbool_t nonzero = svcmpne_n_u8(pg, svld1_u8(pg, data), 0);
+ svuint8_t masked = svsel_u8(nonzero, mask_vec, svdup_u8(0));
+
+ svuint8_t idx = svindex_u8(0, 1);
+ svuint8_t rev_idx = svsub_u8_x(pg, svdup_u8(15), idx);
+ svuint8_t res_hi = svtbl_u8(masked, rev_idx);
+
+ uint32_t mask = static_cast<uint32_t>(svaddv_u16(pg, svreinterpret_u16_u8(svzip1_u8(masked, res_hi))));
+ return mask;
+}
+
Review Comment:
The function bytes32_mask_to_bits32_mask in the benchmark file has a different implementation than the one in be/src/util/simd/bits.h, which may lead to confusion and inconsistent benchmarking results. The benchmark should either use the actual production function from simd::bytes32_mask_to_bits32_mask or clearly document why an alternative implementation is being compared.
```suggestion
// Alternative benchmark-only implementation of converting 32 bytes of
// masked data into a 32-bit mask. The production implementation is
// simd::bytes32_mask_to_bits32_mask (see util/simd/bits.h). This version
// is intentionally different and is used in BM_bytes32_mask_to_bits32_mask_2
// to compare its performance against the production implementation.
```
##########
be/src/util/simd/bits.h:
##########
@@ -81,6 +85,38 @@ inline uint32_t bytes32_mask_to_bits32_mask(const uint8_t* data) {
_mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 16)), zero16)))
<< 16) &
0xffff0000);
+#elif defined(__ARM_FEATURE_SVE)
+ /*
+ * Assume the input data is [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 1. Comparison produces a predicate mask: is_one = [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 2. Construct a new vector: masked = [1, 2, 4, 8, 16, 32, 64, 128,1, 2, 4, 8, 16, 32, 64, 128, 0 (repeated 16 times)].
+ * For each position, if the corresponding element in is_one is 1, take the value from the mask array (mask_arr); otherwise, take 0.
+ *
+ * 3. Rearorder the elements: res = [1, 1, 0, 0, 2, 2, 0, 0, 4, 4, 0, 0, ...], where the index mapping is: j = (i % 4) * 8 + (i / 4).
Review Comment:
The comment in step 3 contains a mathematical expression "j = (i % 4) * 8 + (i / 4)" where the operator precedence is ambiguous. It should be "j = ((i % 4) * 8) + (i / 4)" to clarify that the modulo and multiplication are evaluated before the division and addition, matching the actual code implementation.
##########
be/src/util/simd/bits.h:
##########
@@ -81,6 +85,38 @@ inline uint32_t bytes32_mask_to_bits32_mask(const uint8_t* data) {
_mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 16)), zero16)))
<< 16) &
0xffff0000);
+#elif defined(__ARM_FEATURE_SVE)
+ /*
+ * Assume the input data is [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 1. Comparison produces a predicate mask: is_one = [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 2. Construct a new vector: masked = [1, 2, 4, 8, 16, 32, 64, 128,1, 2, 4, 8, 16, 32, 64, 128, 0 (repeated 16 times)].
+ * For each position, if the corresponding element in is_one is 1, take the value from the mask array (mask_arr); otherwise, take 0.
+ *
+ * 3. Rearorder the elements: res = [1, 1, 0, 0, 2, 2, 0, 0, 4, 4, 0, 0, ...], where the index mapping is: j = (i % 4) * 8 + (i / 4).
Review Comment:
Typo in the comment: "Rearorder" should be "Reorder".
```suggestion
* 3. Reorder the elements: res = [1, 1, 0, 0, 2, 2, 0, 0, 4, 4, 0, 0, ...], where the index mapping is: j = (i % 4) * 8 + (i / 4).
```
##########
be/benchmark/benchmark_bit_simd.hpp:
##########
@@ -0,0 +1,114 @@
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+
+#include <benchmark/benchmark.h>
+#include <vector>
+#include <random>
+
+#include "util/simd/bits.h"
+
+namespace doris {
+
+static void create_test_data(std::vector<uint8_t> &data, size_t size) {
+ std::mt19937 rng(123);
+ for (int i = 0; i < size; ++i) {
+ data[i] = rng() & 1;
+ }
+}
+
+inline uint32_t bitmask_8(const uint8_t* data) {
+ static constexpr uint8_t mask_arr[16] = {1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128};
+ svbool_t pg = svwhilelt_b8(0, 16);
+ svuint8_t mask_vec = svld1_u8(pg, mask_arr);
+
+ svbool_t nonzero = svcmpne_n_u8(pg, svld1_u8(pg, data), 0);
+ svuint8_t masked = svsel_u8(nonzero, mask_vec, svdup_u8(0));
+
+ svuint8_t idx = svindex_u8(0, 1);
+ svuint8_t rev_idx = svsub_u8_x(pg, svdup_u8(15), idx);
+ svuint8_t res_hi = svtbl_u8(masked, rev_idx);
+
+ uint32_t mask = static_cast<uint32_t>(svaddv_u16(pg, svreinterpret_u16_u8(svzip1_u8(masked, res_hi))));
+ return mask;
+}
+
+uint32_t bytes32_mask_to_bits32_mask(const uint8_t* data) {
+ return bitmask_8(data) | (bitmask_8(data + 16) << 16);
+}
Review Comment:
The benchmark file uses SVE intrinsics (svwhilelt_b8, svld1_u8, svcmpne_n_u8, etc.) without including the required header arm_sve.h and without guarding the code with __ARM_FEATURE_SVE preprocessor directive. This will cause compilation failures on systems without SVE support. The SVE-specific code should be wrapped in #if defined(__ARM_FEATURE_SVE) and the header should be conditionally included.
##########
be/src/util/simd/bits.h:
##########
@@ -81,6 +85,38 @@ inline uint32_t bytes32_mask_to_bits32_mask(const uint8_t* data) {
_mm_loadu_si128(reinterpret_cast<const __m128i*>(data + 16)), zero16)))
<< 16) &
0xffff0000);
+#elif defined(__ARM_FEATURE_SVE)
+ /*
+ * Assume the input data is [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 1. Comparison produces a predicate mask: is_one = [1 (repeated 16 times), 0 (repeated 16 times)].
+ *
+ * 2. Construct a new vector: masked = [1, 2, 4, 8, 16, 32, 64, 128,1, 2, 4, 8, 16, 32, 64, 128, 0 (repeated 16 times)].
Review Comment:
There's a spacing issue in the comment. Missing space after "128," before "1" in the sequence. Should be "128, 1, 2, 4..." not "128,1, 2, 4..."
```suggestion
* 2. Construct a new vector: masked = [1, 2, 4, 8, 16, 32, 64, 128, 1, 2, 4, 8, 16, 32, 64, 128, 0 (repeated 16 times)].
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org
Re: [PR] [opt](arm) Improve performance of bytes32_mask_to_bits32_mask functions with SVE intrinsics [doris]
Posted by "doris-robot (via GitHub)" <gi...@apache.org>.
doris-robot commented on PR #59426:
URL: https://github.com/apache/doris/pull/59426#issuecomment-3694574461
<details>
<summary>TPC-H: <b>Total hot run time: 35087 ms</b></summary>
```
machine: 'aliyun_ecs.c7a.8xlarge_32C64G'
scripts: https://github.com/apache/doris/tree/master/tools/tpch-tools
Tpch sf100 test result on commit d860fdfa2cd9ae99881222ad8502aa83759542ae, data reload: false
------ Round 1 ----------------------------------
q1 17621 4536 4059 4059
q2 2015 350 236 236
q3 10181 1337 732 732
q4 10254 936 318 318
q5 7528 2146 1925 1925
q6 190 167 138 138
q7 1008 848 705 705
q8 9375 1474 1165 1165
q9 7165 5420 5371 5371
q10 6846 2431 2000 2000
q11 539 338 301 301
q12 690 739 556 556
q13 17777 3698 3007 3007
q14 290 316 268 268
q15 605 521 516 516
q16 708 676 636 636
q17 694 811 567 567
q18 7758 7215 6963 6963
q19 1152 974 600 600
q20 396 359 257 257
q21 4201 3905 3774 3774
q22 1035 1009 993 993
Total cold run time: 108028 ms
Total hot run time: 35087 ms
----- Round 2, with runtime_filter_mode=off -----
q1 4123 3999 4046 3999
q2 329 393 330 330
q3 2131 2682 2306 2306
q4 1331 1781 1274 1274
q5 4261 4723 4629 4629
q6 239 189 138 138
q7 2085 1966 1895 1895
q8 2672 2570 2512 2512
q9 7562 7499 7534 7499
q10 3086 3262 2856 2856
q11 624 551 513 513
q12 665 898 698 698
q13 3549 4009 3320 3320
q14 312 325 279 279
q15 552 494 518 494
q16 658 693 623 623
q17 1205 1475 1383 1383
q18 8057 7695 7500 7500
q19 863 830 888 830
q20 2002 2061 1954 1954
q21 4619 4224 4231 4224
q22 1118 1034 981 981
Total cold run time: 52043 ms
Total hot run time: 50237 ms
```
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org