starrocks icon indicating copy to clipboard operation
starrocks copied to clipboard

[Enhancement]Add arm neon adaptation for lots of SIMD functions

Open 1153710405 opened this issue 1 year ago • 8 comments

Why I'm doing: Current Starrocks does not support SIMD functions on arm, which leads to a loss in performance.

What I'm doing: Apating the AVX2KI library provided by huawei kunpeng (https://www.hikunpeng.com/zh/developer/boostkit/library/system?subtab=AVX2KI), lots of SIMD functions is implemented on arm.

Fixes #issue

What type of PR is this:

  • [ ] BugFix
  • [ ] Feature
  • [x] Enhancement
  • [ ] Refactor
  • [ ] UT
  • [ ] Doc
  • [ ] Tool

Does this PR entail a change in behavior?

  • [ ] Yes, this PR will result in a change in behavior.
  • [x] No, this PR will not result in a change in behavior.

If yes, please specify the type of change:

  • [ ] Interface/UI changes: syntax, type conversion, expression evaluation, display information
  • [ ] Parameter changes: default values, similar parameters but with different default values
  • [ ] Policy changes: use new policy to replace old one, functionality automatically enabled
  • [ ] Feature removed
  • [x] Miscellaneous: upgrade & downgrade compatibility, etc.

Checklist:

  • [ ] I have added test cases for my bug fix or my new feature
  • [ ] This pr needs user documentation (for new or modified features or behaviors)
  • [ ] I have added documentation for my new feature or new function
  • [ ] This is a backport pr

Bugfix cherry-pick branch check:

  • [x] I have checked the version labels which the pr will be auto-backported to the target branch
    • [ ] 3.2
    • [ ] 3.1
    • [ ] 3.0
    • [ ] 2.5

1153710405 avatar Feb 01 '24 12:02 1153710405

CLA assistant check
All committers have signed the CLA.

CLAassistant avatar Feb 01 '24 12:02 CLAassistant

@1153710405 it's been a while, how's this going on?

kevincai avatar Mar 01 '24 05:03 kevincai

@1153710405 it's been a while, how's this going on?

I was involved in another emergency project before, and will go on this PR this week.

1153710405 avatar Mar 05 '24 13:03 1153710405

@1153710405 is this PR ready for review?

kevincai avatar Mar 19 '24 06:03 kevincai

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Mar 25 '24 02:03 sonarqubecloud[bot]

Generally it works on armv8 based platform. I shall double check whether it works on centos 7 and ubuntu.

Sent from Mail for Windows

From: Kevin Cai Sent: 2024年3月25日 10:30 To: StarRocks/starrocks Cc: 1153710405; Mention Subject: Re: [StarRocks/starrocks] [Enhancement]Add arm neon adaptation forlots of SIMD functions (PR #40569)

@kevincai commented on this pull request.

In thirdparty/build-thirdparty.sh:

@@ -1239,6 +1239,20 @@ build_clucene() { fi }

+# avx2ki +build_avx2ki() {

  • check_if_source_exist $AVX2KI_SOURCE
  • cd $TP_SOURCE_DIR/$AVX2KI_SOURCE
  • rpm2cpio boostkit-ksl-2.0.0-1.aarch64.rpm | cpio -id which platform will this library for, can it work on both centos7 and ubuntu22.04? — Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>

1153710405 avatar Mar 25 '24 14:03 1153710405

@kevincai I have successfully built this branch, but the inspection pipeline still failed on the info job. How should I solve it?

1153710405 avatar May 28 '24 01:05 1153710405

@kevincai I have successfully built this branch, but the inspection pipeline still failed on the info job. How should I solve it?

approve the ci pipeline running. wait for the result, also there are new changes to thirdparty, you may want to rebase to latest main branch and retry again.

kevincai avatar May 28 '24 01:05 kevincai

@kevincai I encounter a new link error related to curl when linking to starrocks_be. Is it related to the newest changes to thirdparty?

/usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:81: undefined reference to psl_latest' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:90: undefined reference to psl_builtin' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-version.o): in function cul_version': ./curl-8.4.0/lib/version.c:214: undefined reference to psl_get_version' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-cookie.o): in function Cur_cookie_add': ./curl-8.4.0/lib/cookie.c:1036: undefined reference to psl_is_cookie_domain_acceptable' collect2: error: ld returned 1 exit status

1153710405 avatar May 28 '24 09:05 1153710405

@kevincai I encounter a new link error related to curl when linking to starrocks_be. Is it related to the newest changes to thirdparty?

/usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:81: undefined reference to psl_latest' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:90: undefined reference to psl_builtin' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-version.o): in function cul_version': ./curl-8.4.0/lib/version.c:214: undefined reference to psl_get_version' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-cookie.o): in function Cur_cookie_add': ./curl-8.4.0/lib/cookie.c:1036: undefined reference to psl_is_cookie_domain_acceptable' collect2: error: ld returned 1 exit status

did you have system-wide curl library installed?

kevincai avatar May 28 '24 09:05 kevincai

@kevincai I encounter a new link error related to curl when linking to starrocks_be. Is it related to the newest changes to thirdparty? /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:81: undefined reference to psl_latest' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:90: undefined reference to psl_builtin' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-version.o): in function cul_version': ./curl-8.4.0/lib/version.c:214: undefined reference to psl_get_version' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-cookie.o): in function Cur_cookie_add': ./curl-8.4.0/lib/cookie.c:1036: undefined reference to psl_is_cookie_domain_acceptable' collect2: error: ld returned 1 exit status

did you have system-wide curl library installed?

No. I can still successfully build this branch in the morning, and there are no any other changes to the system after that.

1153710405 avatar May 28 '24 10:05 1153710405

@kevincai I encounter a new link error related to curl when linking to starrocks_be. Is it related to the newest changes to thirdparty? /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:81: undefined reference to psl_latest' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_destroy': ./curl-8.4.0/lib/psl.c:43: undefined reference to psl_free' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-psl.o): in function Curl_pl_use': ./curl-8.4.0/lib/psl.c:90: undefined reference to psl_builtin' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-version.o): in function cul_version': ./curl-8.4.0/lib/version.c:214: undefined reference to psl_get_version' /usr/bin/ld: /home/hqs/starrocks/starrocks-arm_neon-adaptation-patch/thirdparty/installed/lib/libcurl.a(libcurl_la-cookie.o): in function Cur_cookie_add': ./curl-8.4.0/lib/cookie.c:1036: undefined reference to psl_is_cookie_domain_acceptable' collect2: error: ld returned 1 exit status

did you have system-wide curl library installed?

I add --without-libpsl in the ldflags of curl and this problem is solved. But I still havn't figured out how this problem is triggered, especially when I can still succeed to build the day before.

1153710405 avatar May 30 '24 09:05 1153710405

@kevincai It seems that the pipeline failed in Thirdparty Update due to permission denied when executing build-thirdparty.sh. How can it be solved?

1153710405 avatar May 31 '24 07:05 1153710405

@mergifyio rebase

kevincai avatar Jun 08 '24 11:06 kevincai

rebase

❌ Base branch update has failed

Git reported the following error:

Rebasing (1/25)
Auto-merging thirdparty/vars-aarch64.sh
CONFLICT (content): Merge conflict in thirdparty/vars-aarch64.sh
error: could not apply 17a846d48... Download avx2ki for arm_neon-adaptation
hint: Resolve all conflicts manually, mark them as resolved with
hint: "git add/rm <conflicted_files>", then run "git rebase --continue".
hint: You can instead skip this commit: run "git rebase --skip".
hint: To abort and get back to the state before "git rebase", run "git rebase --abort".
Could not apply 17a846d48... Download avx2ki for arm_neon-adaptation

mergify[bot] avatar Jun 08 '24 11:06 mergify[bot]

@kevincai The pipeline failed at codecov/project/be-total. What is the problem and how should I solve it?

1153710405 avatar Jun 12 '24 02:06 1153710405

**license/cla ** Pending — Contributor License Agreement is not signed yet.

should be fine for that check. it is still optional.

kevincai avatar Jun 12 '24 08:06 kevincai

@kevincai The pipeline failed at codecov/project/be-total. What is the problem and how should I solve it? shall check how to fix the CLA item @1153710405

kevincai avatar Jun 12 '24 08:06 kevincai

@kevincai I update again to solve the conflict with vars-aarch64.sh. Besides, how should I get two approving reviews?

1153710405 avatar Jun 13 '24 07:06 1153710405

Quality Gate Passed Quality Gate passed

Issues
0 New issues
0 Accepted issues

Measures
0 Security Hotspots
No data about Coverage
No data about Duplication

See analysis details on SonarCloud

sonarqubecloud[bot] avatar Jun 13 '24 07:06 sonarqubecloud[bot]

[FE Incremental Coverage Report]

:white_check_mark: pass : 0 / 0 (0%)

github-actions[bot] avatar Jun 13 '24 11:06 github-actions[bot]

[BE Incremental Coverage Report]

:white_check_mark: pass : 1 / 1 (100.00%)

file detail

path covered_line new_line coverage not_covered_line_detail
:large_blue_circle: be/src/exec/arrow_to_starrocks_converter.cpp 1 1 100.00% []

github-actions[bot] avatar Jun 13 '24 11:06 github-actions[bot]

@kevincai @imay Hello, is this PR ready to be merged?

1153710405 avatar Jun 17 '24 01:06 1153710405

Is there a stable reproducible case, I need to confirm the real performance improvement.

stdpain avatar Jun 18 '24 11:06 stdpain

Any performance for SSB/TPC-H/TPC-DS 100G - 1000G scenarios. For operations like move_mask ARM performance is poor. We have adapted the NEON instruction set in our hotspot code, and in gravtion tests it is already doing as well as the X86 platform. So I wouldn't recommend merging into this patch without further significant improvements.

stdpain avatar Jun 18 '24 11:06 stdpain

These hotspot codes are highly inline, and using .so calls breaks the inline and may introduce performance degradation

stdpain avatar Jun 18 '24 11:06 stdpain

https://github.com/StarRocks/starrocks/issues/46174

simde might be an alternative solution to do this.

kevincai avatar Jun 18 '24 16:06 kevincai