Skip to content

Commit

Permalink
*: set right GOMAXPROCS (#171)
Browse files Browse the repository at this point in the history
* *: set right GOMAXPROCS

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>

---------

Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Sep 18, 2023
1 parent 2558e0c commit 10e1032
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 3 deletions.
4 changes: 3 additions & 1 deletion cmd/go-tpc/ch_benchmark.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,9 @@ func registerCHBenchmark(root *cobra.Command) {
}

func executeCH(action string, openAP func() (*sql.DB, error)) {
runtime.GOMAXPROCS(maxProcs)
if maxProcs == 0 {
runtime.GOMAXPROCS(maxProcs)
}

openDB()
defer closeDB()
Expand Down
2 changes: 1 addition & 1 deletion cmd/go-tpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import (

"github.com/pingcap/go-tpc/pkg/util"
"github.com/spf13/cobra"

_ "go.uber.org/automaxprocs"
// mysql package
"github.com/go-sql-driver/mysql"
// pg
Expand Down
4 changes: 3 additions & 1 deletion cmd/go-tpc/tpcc.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@ func executeTpcc(action string) {
}
}()
}
runtime.GOMAXPROCS(maxProcs)
if maxProcs == 0 {
runtime.GOMAXPROCS(maxProcs)
}

openDB()
defer closeDB()
Expand Down
4 changes: 4 additions & 0 deletions cmd/go-tpc/tpch.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"context"
"fmt"
"os"
"runtime"
"strings"

"github.com/pingcap/go-tpc/pkg/util"
Expand All @@ -21,6 +22,9 @@ func executeTpch(action string) {
util.StdErrLogger.Printf("cannot connect to the database")
os.Exit(1)
}
if maxProcs == 0 {
runtime.GOMAXPROCS(maxProcs)
}

tpchConfig.PlanReplayerConfig.Host = hosts[0]
tpchConfig.PlanReplayerConfig.StatusPort = statusPort
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ require (
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.8.0
go.uber.org/atomic v1.9.0
go.uber.org/automaxprocs v1.5.3
golang.org/x/sync v0.1.0
)

Expand Down
4 changes: 4 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI=
github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g=
github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U=
github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw=
github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso=
github.com/prometheus/client_golang v1.15.0 h1:5fCgGYogn0hFdhyhLbw7hEsWxufKtY9klyvdNfFlFhM=
Expand Down Expand Up @@ -409,6 +411,8 @@ go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8=
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
go.uber.org/atomic v1.9.0 h1:ECmE8Bn/WFTYwEW/bpKD3M8VtR/zQVbavAoalC1PYyE=
go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc=
go.uber.org/automaxprocs v1.5.3 h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=
go.uber.org/automaxprocs v1.5.3/go.mod h1:eRbA25aqJrxAbsLO0xy5jVwPt7FQnRgjW+efnwa1WM0=
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
go.uber.org/zap v1.10.0/go.mod h1:vwi/ZaCAaUcBkycHslxD9B2zi4UTXhF60s6SWpuDF0Q=
golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
Expand Down

0 comments on commit 10e1032

Please sign in to comment.