Skip to content

*: use bytes.Equal to check byte slice equivalent (#11706)#16174

Merged
zz-jason merged 6 commits into
pingcap:release-3.0from
sre-bot:release-3.0-3076e632c89e
Apr 13, 2020
Merged

*: use bytes.Equal to check byte slice equivalent (#11706)#16174
zz-jason merged 6 commits into
pingcap:release-3.0from
sre-bot:release-3.0-3076e632c89e

Conversation

@sre-bot
Copy link
Copy Markdown
Contributor

@sre-bot sre-bot commented Apr 8, 2020

cherry-pick #11706 to release-3.0


What problem does this PR solve?

bytes.Equal is faster than bytes.Compare() == 0

simple benchmark code snippet: https://play.golang.org/p/omqWdp4z0S9

➜  go test -bench=. bytes_bench_test.go -run=none
goos: linux
goarch: amd64
BenchmarkCompare-2      300000000                5.80 ns/op
BenchmarkEqual-2        300000000                4.83 ns/op
BenchmarkCompareNE-2    200000000                6.15 ns/op
BenchmarkEqualNE-2      500000000                3.04 ns/op
PASS

What is changed and how it works?

change bytes.Compare() == 0 with bytes.Equal

Check List

Tests

  • Unit test
  • Integration test

Code changes

Side effects

Related changes

  • Need to cherry-pick to the release branch

Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Copy Markdown
Contributor Author

sre-bot commented Apr 8, 2020

/run-all-tests

Copy link
Copy Markdown
Contributor

@AilinKid AilinKid left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Copy Markdown
Member

@zz-jason zz-jason left a comment

Choose a reason for hiding this comment

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

LGTM

@zz-jason zz-jason added status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. labels Apr 13, 2020
@zz-jason zz-jason removed the request for review from ngaut April 13, 2020 07:54
@sre-bot
Copy link
Copy Markdown
Contributor Author

sre-bot commented Apr 13, 2020

/run-all-tests

@sre-bot
Copy link
Copy Markdown
Contributor Author

sre-bot commented Apr 13, 2020

@sre-bot merge failed.

@XuHuaiyu
Copy link
Copy Markdown
Contributor

/rebuild

@XuHuaiyu
Copy link
Copy Markdown
Contributor

/run-sqllogic-test

@zz-jason zz-jason merged commit 3f6a2b9 into pingcap:release-3.0 Apr 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

sig/execution SIG execution status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement. type/3.0-cherry-pick

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants