-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
expression: implement vectorized evaluation for builtinSleepSig
#14070
Closed
shihongzhi
wants to merge
15
commits into
pingcap:master
from
shihongzhi:feature/vec_builtinSleepSig
Closed
Changes from 11 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
43250d7
tmp
shihongzhi 5069a60
Merge branch 'master' into feature/vec_builtinSleepSig
shihongzhi 98667e5
fix
shihongzhi 4acb2ac
set chunksize to 1
shihongzhi 49f024c
add return
shihongzhi a1880d6
refactor: move same code to a method
shihongzhi 542431b
add TestSleepVec
shihongzhi c73fcd8
fix
shihongzhi a7f8e2d
fix
shihongzhi e880ec8
fix https://github.com/pingcap/tidb/pull/14070#discussion_r359170828
shihongzhi bc49dd4
tmp
shihongzhi 69b0fe3
maker sleep time shorter
shihongzhi 6f2837f
add more test case
shihongzhi cd9d2fb
fix
shihongzhi 902c237
tmp
shihongzhi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,11 +17,13 @@ import ( | |
"fmt" | ||
"math/rand" | ||
"sync" | ||
"sync/atomic" | ||
"testing" | ||
"time" | ||
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/errors" | ||
"github.com/pingcap/parser/ast" | ||
"github.com/pingcap/parser/mysql" | ||
"github.com/pingcap/tidb/types" | ||
"github.com/pingcap/tidb/types/json" | ||
|
@@ -783,6 +785,41 @@ func (s *testEvaluatorSuite) TestFloat32ColVec(c *C) { | |
c.Assert(col.VecEvalReal(ctx, chk, result), IsNil) | ||
} | ||
|
||
func (s *testEvaluatorSuite) TestSleepVec(c *C) { | ||
ctx := mock.NewContext() | ||
sessVars := ctx.GetSessionVars() | ||
|
||
fc := funcs[ast.Sleep] | ||
// non-strict model | ||
sessVars.StrictSQLMode = false | ||
d := make([]types.Datum, 1) | ||
f, err := fc.getFunction(ctx, s.datumsToConstants(d)) | ||
c.Assert(err, IsNil) | ||
|
||
start := time.Now() | ||
go func() { | ||
time.Sleep(1 * time.Second) | ||
atomic.CompareAndSwapUint32(&ctx.GetSessionVars().Killed, 0, 1) | ||
}() | ||
|
||
a := float64(3) | ||
tp := new(types.FieldType) | ||
types.DefaultTypeForValue(a, tp) | ||
input := chunk.New([]*types.FieldType{tp}, 1, 1) | ||
buf := chunk.NewColumn(types.NewFieldType(mysql.TypeLonglong), 1) | ||
da := types.Datum{} | ||
da.SetValue(a) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How about add another test for three rows with three arguments of 1 second ? |
||
input.AppendDatum(0, &da) | ||
|
||
c.Assert(f.vecEvalInt(input, buf), IsNil) | ||
|
||
sub := time.Since(start) | ||
c.Assert(buf.IsNull(0), IsFalse) | ||
c.Assert(buf.GetInt64(0), Equals, int64(1)) | ||
c.Assert(sub.Nanoseconds(), LessEqual, int64(2*1e9)) | ||
c.Assert(sub.Nanoseconds(), GreaterEqual, int64(1*1e9)) | ||
} | ||
|
||
func BenchmarkFloat32ColRow(b *testing.B) { | ||
col, chk, _ := genFloat32Col() | ||
ctx := mock.NewContext() | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's still too long, how about keep it in a set of [0, 0.1]?