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

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

Merged
merged 1 commit into from
Aug 11, 2019

Conversation

amyangfei
Copy link
Contributor

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

@amyangfei amyangfei added type/enhancement The issue or PR belongs to an enhancement. needs-cherry-pick-3.0 labels Aug 10, 2019
@codecov
Copy link

codecov bot commented Aug 10, 2019

Codecov Report

Merging #11706 into master will decrease coverage by 0.2948%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11706        +/-   ##
================================================
- Coverage   81.7276%   81.4327%   -0.2949%     
================================================
  Files           430        429         -1     
  Lines         94279      92631      -1648     
================================================
- Hits          77052      75432      -1620     
- Misses        11802      11805         +3     
+ Partials       5425       5394        -31

1 similar comment
@codecov
Copy link

codecov bot commented Aug 10, 2019

Codecov Report

Merging #11706 into master will decrease coverage by 0.2948%.
The diff coverage is 100%.

@@               Coverage Diff                @@
##             master     #11706        +/-   ##
================================================
- Coverage   81.7276%   81.4327%   -0.2949%     
================================================
  Files           430        429         -1     
  Lines         94279      92631      -1648     
================================================
- Hits          77052      75432      -1620     
- Misses        11802      11805         +3     
+ Partials       5425       5394        -31

@amyangfei
Copy link
Contributor Author

/run-all-tests

@ngaut
Copy link
Member

ngaut commented Aug 11, 2019

Good catch. LGTM.

Copy link
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 the status/LGT2 Indicates that a PR has LGTM 2. label Aug 11, 2019
@zz-jason zz-jason merged commit 3076e63 into pingcap:master Aug 11, 2019
@sre-bot
Copy link
Contributor

sre-bot commented Aug 11, 2019

cherry pick to release-3.0 failed

@amyangfei amyangfei deleted the bytes-op-tuning branch August 12, 2019 02:00
@sre-bot
Copy link
Contributor

sre-bot commented Apr 7, 2020

It seems that, not for sure, we failed to cherry-pick this commit to release-3.0. Please comment '/run-cherry-picker' to try to trigger the cherry-picker if we did fail to cherry-pick this commit before. @amyangfei PTAL.

@XuHuaiyu
Copy link
Contributor

XuHuaiyu commented Apr 8, 2020

/run-cherry-picker

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 8, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-3.0 in PR #16174

sre-bot pushed a commit to sre-bot/tidb that referenced this pull request Apr 8, 2020
Signed-off-by: sre-bot <sre-bot@pingcap.com>
@sre-bot
Copy link
Contributor

sre-bot commented Apr 8, 2020

cherry pick to release-3.1 in PR #16177

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status/LGT2 Indicates that a PR has LGTM 2. type/enhancement The issue or PR belongs to an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants