diff options
| author | guol-fnst <guol-fnst@fujitsu.com> | 2022-07-13 09:40:46 +0800 |
|---|---|---|
| committer | guol-fnst <guol-fnst@fujitsu.com> | 2022-07-14 09:57:25 +0800 |
| commit | 308a48c0c20627ea47ddbfe9ba092d1235ab965b (patch) | |
| tree | 94cf0dd10c7e12b52a977ca2d9d0ac91cec17309 /weed/storage/disk_location.go | |
| parent | 26313060a305d429989d554cf0ad061c02b2c6cc (diff) | |
| download | seaweedfs-308a48c0c20627ea47ddbfe9ba092d1235ab965b.tar.xz seaweedfs-308a48c0c20627ea47ddbfe9ba092d1235ab965b.zip | |
optimiz concurrency
user can customize number of workers via env "GOMAXPROCS"
Diffstat (limited to 'weed/storage/disk_location.go')
| -rw-r--r-- | weed/storage/disk_location.go | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/weed/storage/disk_location.go b/weed/storage/disk_location.go index a2a63acbb..69d249259 100644 --- a/weed/storage/disk_location.go +++ b/weed/storage/disk_location.go @@ -5,6 +5,7 @@ import ( "os" "path/filepath" "runtime" + "strconv" "strings" "sync" "time" @@ -208,8 +209,14 @@ func (l *DiskLocation) concurrentLoadingVolumes(needleMapKind NeedleMapKind, con func (l *DiskLocation) loadExistingVolumes(needleMapKind NeedleMapKind) { workerNum := runtime.NumCPU() - if workerNum <= 10 { - workerNum = 10 + val, ok := os.LookupEnv("GOMAXPROCS") + 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) glog.V(0).Infof("Store started on dir: %s with %d volumes max %d", l.Directory, len(l.volumes), l.MaxVolumeCount) |
