Skip to content

Commit

Permalink
Merge pull request #7714 from filecoin-project/feat/sched-review
Browse files Browse the repository at this point in the history
Address Scheduler enhancements (#7703) review
  • Loading branch information
magik6k authored Nov 30, 2021
2 parents 73f16f0 + 71329f6 commit 26c9120
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions extern/sector-storage/manager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ func TestRestartWorker(t *testing.T) {
defer cleanup()

localTasks := []sealtasks.TaskType{
sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTFetch,
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
Expand Down Expand Up @@ -466,7 +466,7 @@ func TestResUse(t *testing.T) {
defer cleanup()

localTasks := []sealtasks.TaskType{
sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTFetch,
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
Expand Down Expand Up @@ -524,7 +524,7 @@ func TestResOverride(t *testing.T) {
defer cleanup()

localTasks := []sealtasks.TaskType{
sealtasks.TTAddPiece, sealtasks.TTPreCommit1, sealtasks.TTCommit1, sealtasks.TTFinalize, sealtasks.TTFetch,
sealtasks.TTAddPiece, sealtasks.TTFetch,
}

wds := datastore.NewMapDatastore()
Expand Down
8 changes: 5 additions & 3 deletions extern/sector-storage/sched_resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,12 @@ func (a *activeResources) canHandleRequest(needRes storiface.Resources, wid stor

vmemNeeded := needRes.MaxMemory + needRes.BaseMinMemory
vmemUsed := a.memUsedMax
if vmemUsed < res.MemUsed+res.MemSwapUsed {
vmemUsed = res.MemUsed + res.MemSwapUsed
workerMemoryReserved := res.MemUsed + res.MemSwapUsed // memory used outside lotus-worker (used by the OS, etc.)

if vmemUsed < workerMemoryReserved {
vmemUsed = workerMemoryReserved
}
vmemAvail := res.MemPhysical + res.MemSwap - vmemUsed
vmemAvail := (res.MemPhysical + res.MemSwap) - vmemUsed

if vmemNeeded > vmemAvail {
log.Debugf("sched: not scheduling on worker %s for %s; not enough virtual memory - need: %dM, have %dM available", wid, caller, vmemNeeded/mib, vmemAvail/mib)
Expand Down
2 changes: 1 addition & 1 deletion extern/sector-storage/storiface/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (

type Resources struct {
MinMemory uint64 `envname:"MIN_MEMORY"` // What Must be in RAM for decent perf
MaxMemory uint64 `envname:"MAX_MEMORY"` // Memory required (swap + ram)
MaxMemory uint64 `envname:"MAX_MEMORY"` // Memory required (swap + ram; peak memory usage during task execution)

// GPUUtilization specifes the number of GPUs a task can use
GPUUtilization float64 `envname:"GPU_UTILIZATION"`
Expand Down
1 change: 1 addition & 0 deletions extern/sector-storage/testworker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func (t *testWorker) Info(ctx context.Context) (storiface.WorkerInfo, error) {
Resources: storiface.WorkerResources{
MemPhysical: res.MinMemory * 3,
MemUsed: res.MinMemory,
MemSwapUsed: 0,
MemSwap: 0,
CPUs: 32,
GPUs: nil,
Expand Down

0 comments on commit 26c9120

Please sign in to comment.