Skip to content

Commit

Permalink
*: track analyze memory usage separately with quota (pingcap#33054)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrysan authored May 10, 2022
1 parent 23c6694 commit 33236ba
Show file tree
Hide file tree
Showing 21 changed files with 374 additions and 82 deletions.
21 changes: 21 additions & 0 deletions config/const.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2022 PingCAP, Inc.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package config

// DefRowsForSampleRate is default sample rows used to calculate samplerate.
const DefRowsForSampleRate = 110000

// TrackMemWhenExceeds is the threshold when memory usage needs to be tracked.
const TrackMemWhenExceeds = 104857600 // 100MB
8 changes: 4 additions & 4 deletions executor/adapter.go
Original file line number Diff line number Diff line change
Expand Up @@ -490,10 +490,10 @@ func (a *ExecStmt) handleNoDelay(ctx context.Context, e Executor, isPessimistic
// `rs.Close` in `handleStmt`
if sc != nil && rs == nil {
if sc.MemTracker != nil {
sc.MemTracker.DetachFromGlobalTracker()
sc.MemTracker.Detach()
}
if sc.DiskTracker != nil {
sc.DiskTracker.DetachFromGlobalTracker()
sc.DiskTracker.Detach()
}
}
}()
Expand Down Expand Up @@ -1009,10 +1009,10 @@ func (a *ExecStmt) CloseRecordSet(txnStartTS uint64, lastErr error) {
// Detach the Memory and disk tracker for the previous stmtCtx from GlobalMemoryUsageTracker and GlobalDiskUsageTracker
if stmtCtx := a.Ctx.GetSessionVars().StmtCtx; stmtCtx != nil {
if stmtCtx.DiskTracker != nil {
stmtCtx.DiskTracker.DetachFromGlobalTracker()
stmtCtx.DiskTracker.Detach()
}
if stmtCtx.MemTracker != nil {
stmtCtx.MemTracker.DetachFromGlobalTracker()
stmtCtx.MemTracker.Detach()
}
}
}
Expand Down
Loading

0 comments on commit 33236ba

Please sign in to comment.