mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
optimiz concurrency
user can customize number of workers via env "GOMAXPROCS"
This commit is contained in:
parent
26313060a3
commit
308a48c0c2
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
@ -208,8 +209,14 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapKind, con
|
||||||
func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) {
|
func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) {
|
||||||
|
|
||||||
workerNum := runtime.NumCPU()
|
workerNum := runtime.NumCPU()
|
||||||
if workerNum <= 10 {
|
val, ok := os.LookupEnv("GOMAXPROCS")
|
||||||
workerNum = 10
|
if ok {
|
||||||
|
num, err := strconv.Atoi(val)
|
||||||
|
if err != nil || num < 1 {
|
||||||
|
num = 10
|
||||||
|
glog.Warningf("failed to set worker number from GOMAXPROCS , set to default:10")
|
||||||
|
}
|
||||||
|
workerNum = num
|
||||||
}
|
}
|
||||||
l.concurrentLoadingVolumes(needleMapKind, workerNum)
|
l.concurrentLoadingVolumes(needleMapKind, workerNum)
|
||||||
glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount)
|
glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount)
|
||||||
|
|
Loading…
Reference in a new issue