Skip to content

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

Merged
zz-jason merged 1 commit into
pingcap:masterfrom
amyangfei:bytes-op-tuning
Aug 11, 2019
Merged

*: use bytes.Equal to check byte slice equivalent#11706
zz-jason merged 1 commit into
pingcap:masterfrom
amyangfei:bytes-op-tuning

Conversation

@amyangfei
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

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
Copy Markdown
Contributor Author

/run-all-tests

@ngaut
Copy link
Copy Markdown
Member

ngaut commented Aug 11, 2019

Good catch. 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 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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