nomad: try to avoid slice resizing when batching
This commit is contained in:
parent
d8e3adfad9
commit
9bd1f267d2
|
@ -1144,8 +1144,13 @@ func (n *Node) UpdateAlloc(args *structs.AllocUpdateRequest, reply *structs.Gene
|
||||||
updates := n.updates
|
updates := n.updates
|
||||||
evals := n.evals
|
evals := n.evals
|
||||||
future := n.updateFuture
|
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.updateFuture = nil
|
||||||
n.updateTimer = nil
|
n.updateTimer = nil
|
||||||
n.updatesLock.Unlock()
|
n.updatesLock.Unlock()
|
||||||
|
|
Loading…
Reference in New Issue