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

executor: accelerate TestMemCount #19581

Merged
merged 8 commits into from
Aug 29, 2020
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions executor/aggfuncs/aggfunc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,8 +241,8 @@ type aggMemTest struct {
isDistinct bool
}

func buildAggMemTester(funcName string, tp byte, numRows int, allocMemDelta int64, updateMemDeltaGens updateMemDeltaGens, isDistinct bool, results ...interface{}) aggMemTest {
aggTest := buildAggTester(funcName, tp, numRows, results)
func buildAggMemTester(funcName string, tp byte, numRows int, allocMemDelta int64, updateMemDeltaGens updateMemDeltaGens, isDistinct bool) aggMemTest {
aggTest := buildAggTester(funcName, tp, numRows)
pt := aggMemTest{
aggTest: aggTest,
allocMemDelta: allocMemDelta,
Expand Down
8 changes: 4 additions & 4 deletions executor/aggfuncs/func_avg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,13 @@ func (s *testSuite) TestAvg(c *C) {
func (s *testSuite) TestMemAvg(c *C) {
tests := []aggMemTest{
buildAggMemTester(ast.AggFuncAvg, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4AvgDecimalSize, defaultUpdateMemDeltaGens, false, nil, 2.0),
aggfuncs.DefPartialResult4AvgDecimalSize, defaultUpdateMemDeltaGens, false),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4AvgDistinctDecimalSize, distinctUpdateMemDeltaGens, true, nil, 2.0),
aggfuncs.DefPartialResult4AvgDistinctDecimalSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4AvgFloat64Size, defaultUpdateMemDeltaGens, false, nil, 2.0),
aggfuncs.DefPartialResult4AvgFloat64Size, defaultUpdateMemDeltaGens, false),
buildAggMemTester(ast.AggFuncAvg, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4AvgDistinctFloat64Size, distinctUpdateMemDeltaGens, true, nil, 2.0),
aggfuncs.DefPartialResult4AvgDistinctFloat64Size, distinctUpdateMemDeltaGens, true),
}
for _, test := range tests {
s.testAggMemFunc(c, test)
Expand Down
28 changes: 12 additions & 16 deletions executor/aggfuncs/func_count_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import (
"github.com/pingcap/parser/ast"
"github.com/pingcap/parser/mysql"
"github.com/pingcap/tidb/executor/aggfuncs"
"github.com/pingcap/tidb/util/israce"
)

func genApproxDistinctMergePartialResult(begin, end uint64) string {
Expand Down Expand Up @@ -103,30 +102,27 @@ func (s *testSuite) TestCount(c *C) {
}

func (s *testSuite) TestMemCount(c *C) {
if israce.RaceEnabled {
c.Skip("skip race test")
}
tests := []aggMemTest{
buildAggMemTester(ast.AggFuncCount, mysql.TypeLonglong, 5,
aggfuncs.DefPartialResult4CountDistinctIntSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctIntSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeFloat, 5,
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDouble, 5,
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctRealSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeNewDecimal, 5,
aggfuncs.DefPartialResult4CountDistinctDecimalSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctDecimalSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeString, 5,
aggfuncs.DefPartialResult4CountDistinctStringSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctStringSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDate, 5,
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeDuration, 5,
aggfuncs.DefPartialResult4CountDistinctDurationSize, distinctUpdateMemDeltaGens, true, 0, 5),
aggfuncs.DefPartialResult4CountDistinctDurationSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncCount, mysql.TypeJSON, 5,
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true, 0, 5),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeLonglong, 100000,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true, 0, 100000),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeString, 100000,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true, 0, 100000),
aggfuncs.DefPartialResult4CountWithDistinctSize, distinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeLonglong, 5,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true),
buildAggMemTester(ast.AggFuncApproxCountDistinct, mysql.TypeString, 5,
aggfuncs.DefPartialResult4ApproxCountDistinctSize, approxCountDistinctUpdateMemDeltaGens, true),
}
for _, test := range tests {
s.testAggMemFunc(c, test)
Expand Down