Skip to content

Commit

Permalink
copr: add ballast mem to reduce the runtime overhead during execution (
Browse files Browse the repository at this point in the history
  • Loading branch information
ti-chi-bot authored May 21, 2024
1 parent 9e5c591 commit 945d07c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions pkg/store/copr/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ go_library(
"//pkg/util/logutil",
"//pkg/util/memory",
"//pkg/util/paging",
"//pkg/util/size",
"//pkg/util/tiflash",
"//pkg/util/tiflashcompute",
"//pkg/util/tracing",
Expand Down
7 changes: 7 additions & 0 deletions pkg/store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"fmt"
"math"
"net"
"runtime"
"strconv"
"strings"
"sync"
Expand Down Expand Up @@ -50,6 +51,7 @@ import (
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/memory"
"github.com/pingcap/tidb/pkg/util/paging"
"github.com/pingcap/tidb/pkg/util/size"
"github.com/pingcap/tidb/pkg/util/tracing"
"github.com/pingcap/tidb/pkg/util/trxevents"
"github.com/pingcap/tipb/go-tipb"
Expand Down Expand Up @@ -822,6 +824,10 @@ func (worker *copIteratorWorker) run(ctx context.Context) {
})
worker.wg.Done()
}()
// 16KB ballast helps grow the stack to the requirement of copIteratorWorker.
// This reduces the `morestack` call during the execution of `handleTask`, thus improvement the efficiency of TiDB.
// TODO: remove ballast after global pool is applied.
ballast := make([]byte, 16*size.KB)
for task := range worker.taskCh {
respCh := worker.respChan
if respCh == nil {
Expand All @@ -840,6 +846,7 @@ func (worker *copIteratorWorker) run(ctx context.Context) {
return
}
}
runtime.KeepAlive(ballast)
}

// open starts workers and sender goroutines.
Expand Down

0 comments on commit 945d07c

Please sign in to comment.