Skip to content

Commit

Permalink
nomad: try to avoid slice resizing when batching
Browse files Browse the repository at this point in the history
  • Loading branch information
schmichael committed Nov 24, 2020
1 parent 84b9dd8 commit 48ec412
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions nomad/node_endpoint.go
Original file line number Diff line number Diff line change
Expand Up @@ -1144,8 +1144,13 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene
updates := n.updates
evals := n.evals
future := n.updateFuture
n.updates = nil
n.evals = nil

// Assume future update patterns will be similar to
// current batch and set cap appropriately to avoid
// slice resizing.
n.updates = make([]*structs.Allocation, 0, len(updates))
n.evals = make([]*structs.Evaluation, 0, len(evals))

n.updateFuture = nil
n.updateTimer = nil
n.updatesLock.Unlock()
Expand Down

0 comments on commit 48ec412

Please sign in to comment.