Skip to content

Commit

Permalink
executor: make memory tracing in ProjectionExec mo ... (#17109) (#17118)
Browse files Browse the repository at this point in the history
  • Loading branch information
sre-bot authored May 14, 2020
1 parent 601a4be commit 1934f34
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
5 changes: 2 additions & 3 deletions executor/projection.go
Original file line number Diff line number Diff line change
Expand Up @@ -421,10 +421,9 @@ func (w *projectionWorker) run(ctx context.Context) {
return
}

mSize := output.chk.MemoryUsage()
// TODO: trace memory used by the evaluatorSuit including all temporal buffers it uses
mSize := output.chk.MemoryUsage() + input.chk.MemoryUsage()
err := w.evaluatorSuit.Run(w.sctx, input.chk, output.chk)
w.proj.memTracker.Consume(output.chk.MemoryUsage() - mSize)
w.proj.memTracker.Consume(output.chk.MemoryUsage() + input.chk.MemoryUsage() - mSize)
output.done <- err

if err != nil {
Expand Down
20 changes: 15 additions & 5 deletions expression/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6353,12 +6353,22 @@ func (s *testIntegrationSuite) TestIssue16505(c *C) {
tk.MustExec("drop table t;")
}

func (s *testIntegrationSuite) TestIssue17045(c *C) {
func (s *testIntegrationSuite) TestIssue16697(c *C) {
tk := testkit.NewTestKit(c, s.store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t")
tk.MustExec("create table t(a int,b varchar(20),c datetime,d double,e int,f int as(a+b),key(a),key(b),key(c),key(d),key(e),key(f));")
tk.MustExec("insert into t(a,b,e) values(null,\"5\",null);")
tk.MustExec("insert into t(a,b,e) values(\"5\",null,null);")
tk.MustQuery("select /*+ use_index_merge(t)*/ * from t where t.e=5 or t.a=5;").Check(testkit.Rows("5 <nil> <nil> <nil> <nil> <nil>"))
tk.MustExec("CREATE TABLE `t` (`a` int(11) DEFAULT NULL,`b` int(11) DEFAULT NULL)")
tk.MustExec("insert into t values (1, 1)")
for i := 0; i < 8; i++ {
tk.MustExec("insert into t select * from t")
}
rows := tk.MustQuery("explain analyze select t1.a, t1.a +1 from t t1 join t t2 join t t3 order by t1.a").Rows()
for _, row := range rows {
line := fmt.Sprintf("%v", row)
if strings.Contains(line, "Projection") {
c.Assert(strings.Contains(line, "KB"), IsTrue)
c.Assert(strings.Contains(line, "MB"), IsFalse)
c.Assert(strings.Contains(line, "GB"), IsFalse)
}
}
}

0 comments on commit 1934f34

Please sign in to comment.