Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[YUNIKORN-2951] Remove unnecessary locking from RequiredNodePreemptor #989

Closed
wants to merge 1 commit into from
Closed
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: 0 additions & 11 deletions pkg/scheduler/objects/required_node_preemptor.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,12 @@ import (
"sort"

"github.com/apache/yunikorn-core/pkg/common/resources"
"github.com/apache/yunikorn-core/pkg/locking"
)

type PreemptionContext struct {
node *Node
requiredAsk *Allocation
allocations []*Allocation

locking.RWMutex
}

func NewRequiredNodePreemptor(node *Node, requiredAsk *Allocation) *PreemptionContext {
Expand All @@ -43,8 +40,6 @@ func NewRequiredNodePreemptor(node *Node, requiredAsk *Allocation) *PreemptionCo
}

func (p *PreemptionContext) filterAllocations() {
p.Lock()
defer p.Unlock()
for _, allocation := range p.node.GetYunikornAllocations() {
// skip daemon set pods and higher priority allocation
if allocation.GetRequiredNode() != "" || allocation.GetPriority() > p.requiredAsk.GetPriority() {
Expand Down Expand Up @@ -76,8 +71,6 @@ func (p *PreemptionContext) filterAllocations() {
// 3. By Create time or age of the ask (younger ask placed first),
// 4. By resource (ask with lesser allocated resources placed first)
func (p *PreemptionContext) sortAllocations() {
p.Lock()
defer p.Unlock()
sort.SliceStable(p.allocations, func(i, j int) bool {
l := p.allocations[i]
r := p.allocations[j]
Expand Down Expand Up @@ -129,8 +122,6 @@ func (p *PreemptionContext) sortAllocations() {
}

func (p *PreemptionContext) GetVictims() []*Allocation {
p.RLock()
defer p.RUnlock()
var victims []*Allocation
var currentResource = resources.NewResource()
for _, allocation := range p.allocations {
Expand All @@ -152,7 +143,5 @@ func (p *PreemptionContext) GetVictims() []*Allocation {

// for test only
func (p *PreemptionContext) getAllocations() []*Allocation {
p.RLock()
defer p.RUnlock()
return p.allocations
}
Loading