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

plan: rewrite "hashCode()" for "requiredProp" #4460

Merged
merged 5 commits into from Sep 7, 2017

Conversation

Projects
None yet
4 participants
@zz-jason
Member

zz-jason commented Sep 7, 2017

fix #4439

package plan

import (
        "testing"

        "github.com/pingcap/tidb/expression"
)

func createProp() *requiredProp {
        col1 := &expression.Column{
                FromID:   1,
                Position: 12,
        }
        col2 := &expression.Column{
                FromID:   11,
                Position: 2,
        }

        return &requiredProp{
                desc:        true,
                taskTp:      12,
                expectedCnt: 1.998,
                cols:        []*expression.Column{col1, col2},
        }
}

func BenchmarkHashCodeNew(b *testing.B) {
        p := createProp()

        b.ResetTimer()
        for i := 0; i < b.N; i++ {
                p.hashcode = nil
                _ = p.hashCode()
        }
}

func BenchmarkHashCodeOrigin(b *testing.B) {
        p := createProp()

        b.ResetTimer()
        for i := 0; i < b.N; i++ {
                _, _ = p.getHashKey()
        }
}
$go test -bench=. -run=BenchmarkHashCode
BenchmarkHashCodeNew-8          20000000                67.9 ns/op
BenchmarkHashCodeOrigin-8        2000000               675 ns/op
PASS
ok      github.com/pingcap/tidb/plan    3.503s
@zz-jason

This comment has been minimized.

Show comment
Hide comment
@zz-jason

zz-jason Sep 7, 2017

Member

/run-all-test

Member

zz-jason commented Sep 7, 2017

/run-all-test

@coocood

This comment has been minimized.

Show comment
Hide comment
@coocood

coocood Sep 7, 2017

Member

LGTM

Member

coocood commented Sep 7, 2017

LGTM

Show outdated Hide outdated plan/plan.go
@@ -296,12 +305,9 @@ func (bp *basePhysicalPlan) ExplainInfo() string {
return ""
}
func (p *baseLogicalPlan) getTask(prop *requiredProp) (task, error) {
key, err := prop.getHashKey()

This comment has been minimized.

@XuHuaiyu

XuHuaiyu Sep 7, 2017

Contributor

getHashKey can be removed?

@XuHuaiyu

XuHuaiyu Sep 7, 2017

Contributor

getHashKey can be removed?

This comment has been minimized.

@zz-jason

zz-jason Sep 7, 2017

Member

already removed.

@zz-jason

zz-jason Sep 7, 2017

Member

already removed.

@hanfei1991

LGTM

@XuHuaiyu XuHuaiyu merged commit 8cb0ceb into master Sep 7, 2017

4 checks passed

ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
jenkins-ci-tidb/build Jenkins job succeeded.
Details
license/cla Contributor License Agreement is signed.
Details

@XuHuaiyu XuHuaiyu deleted the zz-jason/plan/performance/4439 branch Sep 7, 2017

mccxj added a commit to mccxj/tidb that referenced this pull request Sep 7, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment