mirror of
https://github.com/pomerium/pomerium.git
synced 2025-04-28 18:06:34 +02:00
core/go: use max procs (#4766)
* core/go: use max procs * update test * logging
This commit is contained in:
parent
9db828ffd4
commit
ce8abde236
5 changed files with 10 additions and 12 deletions
|
@ -8,6 +8,7 @@ import (
|
|||
"fmt"
|
||||
|
||||
"github.com/rs/zerolog"
|
||||
"go.uber.org/automaxprocs/maxprocs"
|
||||
|
||||
"github.com/pomerium/pomerium/config"
|
||||
"github.com/pomerium/pomerium/internal/log"
|
||||
|
@ -30,6 +31,8 @@ func main() {
|
|||
return
|
||||
}
|
||||
|
||||
_, _ = maxprocs.Set(maxprocs.Logger(func(s string, i ...interface{}) { log.Info(context.Background()).Msgf(s, i...) }))
|
||||
|
||||
ctx := context.Background()
|
||||
runFn := run
|
||||
if zero_cmd.IsManagedMode(*configFile) {
|
||||
|
|
1
go.mod
1
go.mod
|
@ -64,6 +64,7 @@ require (
|
|||
github.com/volatiletech/null/v9 v9.0.0
|
||||
github.com/yuin/gopher-lua v1.1.0
|
||||
go.opencensus.io v0.24.0
|
||||
go.uber.org/automaxprocs v1.5.3
|
||||
go.uber.org/zap v1.26.0
|
||||
golang.org/x/crypto v0.16.0
|
||||
golang.org/x/exp v0.0.0-20230713183714-613f0c0eb8a1
|
||||
|
|
4
go.sum
4
go.sum
|
@ -643,6 +643,8 @@ github.com/pomerium/zero-sdk v0.0.0-20231127153820-dcd408d87b54 h1:pIjWOs15zJq9X
|
|||
github.com/pomerium/zero-sdk v0.0.0-20231127153820-dcd408d87b54/go.mod h1:b3979nx45mwDaeIQQe5T11XjxMUQntc4H3v+szdsHUc=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c h1:ncq/mPwQF4JjgDlrVEn3C11VoGHZN7m8qihwgMEtzYw=
|
||||
github.com/power-devops/perfstat v0.0.0-20210106213030-5aafc221ea8c/go.mod h1:OmDBASR4679mdNQnz2pUhc2G8CO2JrUAVFDRBDP/hJE=
|
||||
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.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo=
|
||||
|
@ -853,6 +855,8 @@ go.opentelemetry.io/proto/otlp v0.19.0/go.mod h1:H7XAot3MsfNsj7EXtrA2q5xSNQ10UqI
|
|||
go.uber.org/atomic v1.4.0/go.mod h1:gD2HeocX3+yG+ygLZcrzQJaqmWj9AIm7n08wl/qW/PE=
|
||||
go.uber.org/atomic v1.11.0 h1:ZvwS0R+56ePWxUNi+Atn9dWONBPp/AUETXlHW0DxSjE=
|
||||
go.uber.org/atomic v1.11.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0=
|
||||
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/goleak v1.2.1 h1:NBol2c7O1ZokfZ0LEU9K6Whx/KnwvepVetCUhtKja4A=
|
||||
go.uber.org/goleak v1.2.1/go.mod h1:qlT2yGI9QafXHhZZLxlSuNsMw3FFLxBr+tBRlmO1xH4=
|
||||
go.uber.org/multierr v1.1.0/go.mod h1:wR5kodmAFQ0UK8QlbwjlSNy0Z68gJhDJUG5sjR94q/0=
|
||||
|
|
|
@ -20,7 +20,7 @@ func Build[T any](
|
|||
builders ...BuilderFunc[T],
|
||||
) ([]*T, []error) {
|
||||
eg, ctx := errgroup.WithContext(ctx)
|
||||
eg.SetLimit(runtime.NumCPU()/2 + 1)
|
||||
eg.SetLimit(runtime.GOMAXPROCS(0)/2 + 1)
|
||||
|
||||
results := make([]*T, len(builders))
|
||||
errors := make([]error, len(builders))
|
||||
|
|
|
@ -5,9 +5,7 @@ package storagetest
|
|||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"runtime"
|
||||
"strconv"
|
||||
"sync"
|
||||
"testing"
|
||||
|
||||
|
@ -115,7 +113,7 @@ func TestBackendPatch(t *testing.T, ctx context.Context, backend storage.Backend
|
|||
})
|
||||
|
||||
t.Run("concurrent", func(t *testing.T) {
|
||||
if n := gomaxprocs(); n < 2 {
|
||||
if n := runtime.GOMAXPROCS(0); n < 2 {
|
||||
t.Skipf("skipping concurrent test (GOMAXPROCS = %d)", n)
|
||||
}
|
||||
|
||||
|
@ -177,11 +175,3 @@ func truncateTimestamps(ts ...*timestamppb.Timestamp) {
|
|||
t.Nanos = (t.Nanos / 1000) * 1000
|
||||
}
|
||||
}
|
||||
|
||||
func gomaxprocs() int {
|
||||
env := os.Getenv("GOMAXPROCS")
|
||||
if n, err := strconv.Atoi(env); err == nil {
|
||||
return n
|
||||
}
|
||||
return runtime.NumCPU()
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue