Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions plugin/gthulhu/gthulhu.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package gthulhu
import (
"context"
"log"
"maps"
"sync"
"time"

Expand Down Expand Up @@ -66,9 +67,8 @@ type GthulhuPlugin struct {
// Global vruntime
minVruntime uint64

// strategyMap is the latest desired strategy set (keyed by task id);
// appliedStrategyMap is the set last handed to the scheduler, so
// GetChangedStrategies can diff the two into a coalesced changed/removed set.
// strategyMap is the desired set; appliedStrategyMap is the last set handed
// to the scheduler. GetChangedStrategies diffs them into changed/removed.
strategyMap map[int32]util.SchedulingStrategy
appliedStrategyMap map[int32]util.SchedulingStrategy
strategyMu sync.RWMutex
Expand Down Expand Up @@ -419,9 +419,6 @@ func (g *GthulhuPlugin) GetChangedStrategies() ([]util.SchedulingStrategy, []uti
}
}

g.appliedStrategyMap = make(map[int32]util.SchedulingStrategy, len(g.strategyMap))
for pid, strategy := range g.strategyMap {
g.appliedStrategyMap[pid] = strategy
}
g.appliedStrategyMap = maps.Clone(g.strategyMap)
return changed, removed
}
4 changes: 2 additions & 2 deletions plugin/gthulhu/gthulhu_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ func TestGetChangedStrategiesConcurrent(t *testing.T) {
g.UpdateStrategyMap([]util.SchedulingStrategy{{PID: 1, Priority: 1}})

var wg sync.WaitGroup
for i := 0; i < 4; i++ {
for range 4 {
wg.Add(1)
go func() {
defer wg.Done()
for j := 0; j < 500; j++ {
for range 500 {
g.GetChangedStrategies()
}
}()
Expand Down
Loading