set worker counts for pre-migrations
This commit is contained in:
parent
cffeb1a590
commit
bceb246080
@ -4,6 +4,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"context"
|
"context"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"runtime"
|
||||||
"sort"
|
"sort"
|
||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
@ -885,8 +886,13 @@ func UpgradeCalico(ctx context.Context, sm *StateManager, _ MigrationCache, cb E
|
|||||||
}
|
}
|
||||||
|
|
||||||
func UpgradeActorsV3(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecCallback, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
func UpgradeActorsV3(ctx context.Context, sm *StateManager, cache MigrationCache, cb ExecCallback, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) (cid.Cid, error) {
|
||||||
// TODO: tune this.
|
// Use all the CPUs except 3.
|
||||||
config := nv10.Config{MaxWorkers: 1}
|
workerCount := runtime.NumCPU() - 3
|
||||||
|
if workerCount <= 0 {
|
||||||
|
workerCount = 1
|
||||||
|
}
|
||||||
|
|
||||||
|
config := nv10.Config{MaxWorkers: uint(workerCount)}
|
||||||
newRoot, err := upgradeActorsV3Common(ctx, sm, cache, root, epoch, ts, config)
|
newRoot, err := upgradeActorsV3Common(ctx, sm, cache, root, epoch, ts, config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return cid.Undef, xerrors.Errorf("migrating actors v3 state: %w", err)
|
return cid.Undef, xerrors.Errorf("migrating actors v3 state: %w", err)
|
||||||
@ -908,8 +914,14 @@ func UpgradeActorsV3(ctx context.Context, sm *StateManager, cache MigrationCache
|
|||||||
}
|
}
|
||||||
|
|
||||||
func PreUpgradeActorsV3(ctx context.Context, sm *StateManager, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
|
func PreUpgradeActorsV3(ctx context.Context, sm *StateManager, cache MigrationCache, root cid.Cid, epoch abi.ChainEpoch, ts *types.TipSet) error {
|
||||||
// TODO: tune this.
|
// Use half the CPUs for pre-migration, but leave at least 3.
|
||||||
config := nv10.Config{MaxWorkers: 1}
|
workerCount := runtime.NumCPU()
|
||||||
|
if workerCount <= 4 {
|
||||||
|
workerCount = 1
|
||||||
|
} else {
|
||||||
|
workerCount /= 2
|
||||||
|
}
|
||||||
|
config := nv10.Config{MaxWorkers: uint(workerCount)}
|
||||||
_, err := upgradeActorsV3Common(ctx, sm, cache, root, epoch, ts, config)
|
_, err := upgradeActorsV3Common(ctx, sm, cache, root, epoch, ts, config)
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user