-
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
planner, executor: set memory size to MAXUint64 for prepare plan cache test #8556
Changes from 1 commit
86d264c
3772c6b
f5a39d8
98ad364
3a6fb98
fcacd45
1d89678
a709b6b
1a45686
d3ccad8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,6 @@ import ( | |
"github.com/pingcap/tidb/executor" | ||
"github.com/pingcap/tidb/metrics" | ||
plannercore "github.com/pingcap/tidb/planner/core" | ||
"github.com/pingcap/tidb/util/memory" | ||
"github.com/pingcap/tidb/util/testkit" | ||
dto "github.com/prometheus/client_model/go" | ||
"golang.org/x/net/context" | ||
|
@@ -47,7 +46,9 @@ func (s *testSuite) TestPrepared(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -253,7 +254,9 @@ func (s *testSuite) TestPreparedLimitOffset(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -296,7 +299,9 @@ func (s *testSuite) TestPreparedNullParam(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -368,7 +373,9 @@ func (s *testSuite) TestPrepareWithAggregation(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -413,7 +420,9 @@ func (s *testSuite) TestPreparedIssue7579(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -467,7 +476,9 @@ func (s *testSuite) TestPreparedInsert(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -549,7 +560,9 @@ func (s *testSuite) TestPreparedUpdate(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -608,7 +621,9 @@ func (s *testSuite) TestPreparedDelete(c *C) { | |
plannercore.SetPreparedPlanCache(flag) | ||
plannercore.PreparedPlanCacheCapacity = 100 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk := testkit.NewTestKit(c, s.store) | ||
tk.MustExec("use test") | ||
|
@@ -662,7 +677,9 @@ func (s *testSuite) TestPrepareDealloc(c *C) { | |
plannercore.SetPreparedPlanCache(true) | ||
plannercore.PreparedPlanCacheCapacity = 3 | ||
plannercore.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
plannercore.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
plannercore.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
|
||
tk := testkit.NewTestKit(c, s.store) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,11 @@ | |
package core_test | ||
|
||
import ( | ||
"math" | ||
|
||
. "github.com/pingcap/check" | ||
"github.com/pingcap/tidb/metrics" | ||
"github.com/pingcap/tidb/planner/core" | ||
"github.com/pingcap/tidb/util/memory" | ||
"github.com/pingcap/tidb/util/testkit" | ||
"github.com/pingcap/tidb/util/testleak" | ||
dto "github.com/prometheus/client_model/go" | ||
|
@@ -48,7 +49,9 @@ func (s *testPointGetSuite) TestPointGetPlanCache(c *C) { | |
core.SetPreparedPlanCache(true) | ||
core.PreparedPlanCacheCapacity = 100 | ||
core.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
core.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
core.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk.MustExec("use test") | ||
tk.MustExec("drop table if exists t") | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ | |
package core_test | ||
|
||
import ( | ||
"math" | ||
"strconv" | ||
"time" | ||
|
||
|
@@ -24,7 +25,6 @@ import ( | |
"github.com/pingcap/tidb/metrics" | ||
"github.com/pingcap/tidb/planner/core" | ||
"github.com/pingcap/tidb/sessionctx/variable" | ||
"github.com/pingcap/tidb/util/memory" | ||
"github.com/pingcap/tidb/util/testkit" | ||
"github.com/pingcap/tidb/util/testleak" | ||
"github.com/prometheus/client_golang/prometheus" | ||
|
@@ -56,7 +56,9 @@ func (s *testPrepareSuite) TestPrepareCache(c *C) { | |
core.SetPreparedPlanCache(true) | ||
core.PreparedPlanCacheCapacity = 100 | ||
core.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
core.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
core.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk.MustExec("use test") | ||
tk.MustExec("drop table if exists t") | ||
|
@@ -105,7 +107,9 @@ func (s *testPrepareSuite) TestPrepareCacheIndexScan(c *C) { | |
core.SetPreparedPlanCache(true) | ||
core.PreparedPlanCacheCapacity = 100 | ||
core.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
core.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
core.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk.MustExec("use test") | ||
tk.MustExec("drop table if exists t") | ||
|
@@ -138,7 +142,9 @@ func (s *testPlanSuite) TestPrepareCacheDeferredFunction(c *C) { | |
core.SetPreparedPlanCache(true) | ||
core.PreparedPlanCacheCapacity = 100 | ||
core.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
core.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
core.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
|
||
defer testleak.AfterTest(c)() | ||
|
@@ -198,7 +204,9 @@ func (s *testPrepareSuite) TestPrepareCacheNow(c *C) { | |
core.SetPreparedPlanCache(true) | ||
core.PreparedPlanCacheCapacity = 100 | ||
core.PreparedPlanCacheMemoryGuardRatio = 0.1 | ||
core.PreparedPlanCacheMaxMemory, err = memory.MemTotal() | ||
// PreparedPlanCacheMaxMemory is set to MAX_UINT64 to make sure the cache | ||
// behavior would not be effected by the uncertain memory utilization. | ||
core.PreparedPlanCacheMaxMemory = math.MaxUint64 | ||
c.Assert(err, IsNil) | ||
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. ditto |
||
tk.MustExec("use test") | ||
tk.MustExec(`prepare stmt1 from "select now(), sleep(1), now()"`) | ||
|
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.
Would you remove the line of the error checking, which is related with
memory.MemTotal()
?