Skip to content

Commit 9585aa6

Browse files
committed
cmd/gitbase: use runtime.NumCPU as default parallelism value
Signed-off-by: Miguel Molina <[email protected]>
1 parent 0c360e8 commit 9585aa6

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

cmd/gitbase/command/server.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import (
44
"net"
55
"os"
66
"path/filepath"
7+
"runtime"
78
"strconv"
89
"strings"
910

@@ -51,7 +52,7 @@ type Server struct {
5152
DisableSquash bool `long:"no-squash" description:"Disables the table squashing."`
5253
TraceEnabled bool `long:"trace" env:"GITBASE_TRACE" description:"Enables jaeger tracing"`
5354
ReadOnly bool `short:"r" long:"readonly" description:"Only allow read queries. This disables creating and deleting indexes as well." env:"GITBASE_READONLY"`
54-
Parallelism uint `long:"parallelism" default:"4" description:"Maximum number of parallel threads per table."`
55+
Parallelism uint `long:"parallelism" description:"Maximum number of parallel threads per table. By default, it's the number of CPU cores. 0 means default, 1 means disabled."`
5556

5657
SkipGitErrors bool // SkipGitErrors disables failing when Git errors are found.
5758
DisableGit bool `long:"no-git" description:"disable the load of git standard repositories."`
@@ -80,6 +81,10 @@ func NewDatabaseEngine(
8081
ab = ab.ReadOnly()
8182
}
8283

84+
if parallelism == 0 {
85+
parallelism = runtime.NumCPU()
86+
}
87+
8388
if parallelism > 1 {
8489
ab = ab.WithParallelism(parallelism)
8590
}

0 commit comments

Comments
 (0)