Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

expression: implement vectorized evaluation for builtinVectorFloat32 #55254

Merged
merged 5 commits into from
Oct 8, 2024

Conversation

EricZequan
Copy link
Contributor

@EricZequan EricZequan commented Aug 7, 2024

What problem does this PR solve?

Issue Number: ref #54245

Problem Summary:
Implement vectorized evaluation for builtinVecDimsSig, builtinVecL1DistanceSig, builtinVecL2DistanceSig, builtinVecNegativeInnerProductSig, builtinVecCosineDistanceSig, builtinVecL2NormSig, builtinVecFromTextSig, builtinVecAsTextSig

What changed and how does it work?

The benchmark shows that the performance almost 1.5x fater than before.
builtinVecAsTextSig and builtinVecFromTextSig maintain similar performance after vectorization.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
goos: darwin
goarch: arm64
pkg: github.com/pingcap/tidb/pkg/expression
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-VecBuiltinFunc-8         	   91862	     13229 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-NonVecBuiltinFunc-8      	   59492	     20113 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-VecBuiltinFunc#01-8      	  941388	      1301 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-NonVecBuiltinFunc#01-8   	  105184	     11463 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-VecBuiltinFunc#02-8      	 1000000	      1112 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-NonVecBuiltinFunc#02-8   	  180105	      6701 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-VecBuiltinFunc#03-8      	   67474	     17779 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecCosineDistanceSig-NonVecBuiltinFunc#03-8   	   40598	     29538 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-VecBuiltinFunc-8   	   99116	     12042 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-NonVecBuiltinFunc-8         	   61656	     19307 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-VecBuiltinFunc#01-8         	  950893	      1308 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-NonVecBuiltinFunc#01-8      	  102386	     11614 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-VecBuiltinFunc#02-8         	 1000000	      1068 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecNegativeInnerProductSig-NonVecBuiltinFunc#02-8      	  177921	      6726 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2NormSig-VecBuiltinFunc-8                          	  187917	      6342 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2NormSig-NonVecBuiltinFunc-8                       	   88740	     11773 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2NormSig-VecBuiltinFunc#01-8                       	 1436419	       818.2 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2NormSig-NonVecBuiltinFunc#01-8                    	  179916	      6678 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecAsTextSig-VecBuiltinFunc-8                          	    5595	    206589 ns/op	   98946 B/op	    3722 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecAsTextSig-NonVecBuiltinFunc-8                       	    5821	    208008 ns/op	   98944 B/op	    3722 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecAsTextSig-VecBuiltinFunc#01-8                       	  735926	      1638 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecAsTextSig-NonVecBuiltinFunc#01-8                    	  248377	      4854 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecFromTextSig-VecBuiltinFunc-8                        	    8546	    133772 ns/op	  204811 B/op	    5120 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecFromTextSig-NonVecBuiltinFunc-8                     	    8816	    137360 ns/op	  204800 B/op	    5120 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecFromTextSig-VecBuiltinFunc#01-8                     	  734040	      1617 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecFromTextSig-NonVecBuiltinFunc#01-8                  	  243121	      4855 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecDimsSig-VecBuiltinFunc-8                            	  279516	      4349 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecDimsSig-NonVecBuiltinFunc-8                         	  125860	      9396 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecDimsSig-VecBuiltinFunc#01-8                         	 1429896	       834.7 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecDimsSig-NonVecBuiltinFunc#01-8                      	  179166	      6665 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-VecBuiltinFunc-8                      	   43821	     27381 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-NonVecBuiltinFunc-8                   	   33884	     35434 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-VecBuiltinFunc#01-8                   	  933763	      1299 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-NonVecBuiltinFunc#01-8                	  102906	     11725 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-VecBuiltinFunc#02-8                   	 1000000	      1084 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL1DistanceSig-NonVecBuiltinFunc#02-8                	  183038	      6588 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-VecBuiltinFunc-8                      	  100116	     11971 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-NonVecBuiltinFunc-8                   	   62168	     19728 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-VecBuiltinFunc#01-8                   	  939297	      1332 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-NonVecBuiltinFunc#01-8                	  106024	     11305 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-VecBuiltinFunc#02-8                   	 1000000	      1325 ns/op	       0 B/op	       0 allocs/op
BenchmarkVectorizedBuiltinVecFunc/builtinVecL2DistanceSig-NonVecBuiltinFunc#02-8                	  173904	      6700 ns/op	       0 B/op	       0 allocs/op
PASS
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

@ti-chi-bot ti-chi-bot bot added release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 7, 2024
Copy link

tiprow bot commented Aug 7, 2024

Hi @EricZequan. Thanks for your PR.

PRs from untrusted users cannot be marked as trusted with /ok-to-test in this repo meaning untrusted PR authors can never trigger tests themselves. Collaborators can still trigger tests on the PR using /test all.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

Copy link

codecov bot commented Aug 7, 2024

Codecov Report

Attention: Patch coverage is 61.38996% with 100 lines in your changes missing coverage. Please review.

Project coverage is 75.4494%. Comparing base (7daf026) to head (540599d).
Report is 3 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #55254        +/-   ##
================================================
+ Coverage   73.3685%   75.4494%   +2.0809%     
================================================
  Files          1624       1625         +1     
  Lines        448117     448976       +859     
================================================
+ Hits         328777     338750      +9973     
+ Misses        99198      89654      -9544     
- Partials      20142      20572       +430     
Flag Coverage Δ
integration 48.9852% <0.0000%> (?)
unit 72.6007% <61.3899%> (+0.1398%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 52.9478% <ø> (ø)
parser ∅ <ø> (∅)
br 52.2826% <ø> (+6.7696%) ⬆️

@EricZequan
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Aug 9, 2024

@EricZequan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@ti-chi-bot ti-chi-bot bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 12, 2024
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 13, 2024
Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Wrong approval

@ti-chi-bot ti-chi-bot bot removed the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Aug 13, 2024
@ti-chi-bot ti-chi-bot bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 13, 2024
@EricZequan
Copy link
Contributor Author

@breezewish Updated. This pr is ready for review.

Copy link
Member

@breezewish breezewish left a comment

Choose a reason for hiding this comment

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

Looks good! Please also find other reviewers for more approvals.

@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Oct 7, 2024
Copy link
Contributor

@windtalker windtalker left a comment

Choose a reason for hiding this comment

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

lgtm

@ti-chi-bot ti-chi-bot bot added lgtm approved and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Oct 8, 2024
Copy link

ti-chi-bot bot commented Oct 8, 2024

[LGTM Timeline notifier]

Timeline:

  • 2024-08-13 06:00:30.515888138 +0000 UTC m=+247715.219357780: ☑️ agreed by breezewish.
  • 2024-08-13 06:00:58.27884302 +0000 UTC m=+247742.982312677: ✖️🔁 reset by breezewish.
  • 2024-10-07 05:57:30.891070328 +0000 UTC m=+852806.311283338: ☑️ agreed by breezewish.
  • 2024-10-08 01:55:58.230495054 +0000 UTC m=+924713.650708066: ☑️ agreed by windtalker.

@EricZequan
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Oct 8, 2024

@EricZequan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@EricZequan
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Oct 8, 2024

@EricZequan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@EricZequan
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Oct 8, 2024

@EricZequan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@EricZequan
Copy link
Contributor Author

/retest

Copy link

tiprow bot commented Oct 8, 2024

@EricZequan: Cannot trigger testing until a trusted user reviews the PR and leaves an /ok-to-test message.

In response to this:

/retest

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@breezewish
Copy link
Member

/retest

@EricZequan EricZequan changed the base branch from feature/vector-search/vector-data-type to master October 8, 2024 06:45
Signed-off-by: “EricZequan” <[email protected]>
Signed-off-by: “EricZequan” <[email protected]>
Copy link

ti-chi-bot bot commented Oct 8, 2024

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: breezewish, windtalker

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

Signed-off-by: “EricZequan” <[email protected]>
Signed-off-by: “EricZequan” <[email protected]>
Copy link

ti-chi-bot bot commented Oct 8, 2024

@EricZequan: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-lightning-integration-test 59c571c link true /test pull-lightning-integration-test
pull-br-integration-test 59c571c link true /test pull-br-integration-test

Full PR test history. Your PR dashboard.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here.

Signed-off-by: “EricZequan” <[email protected]>
@ti-chi-bot ti-chi-bot bot merged commit dcfec4b into pingcap:master Oct 8, 2024
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants