Skip to content

Commit

Permalink
Reduced reallocation of batch+entries (#202)
Browse files Browse the repository at this point in the history
  • Loading branch information
coufalja authored and lni committed Jan 13, 2022
1 parent dee335b commit 9d429ab
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -1125,16 +1125,21 @@ func (e *engine) applyWorkerMain(workerID uint64) {
batch := make([]rsm.Task, 0, taskBatchSize)
entries := make([]sm.Entry, 0, taskBatchSize)
cci := uint64(0)
count := uint64(0)
for {
select {
case <-e.taskStopper.ShouldStop():
e.offloadNodeMap(nodes)
return
case <-ticker.C:
nodes, cci = e.loadApplyNodes(workerID, cci, nodes)
e.processApplies(make(map[uint64]struct{}), nodes, batch, entries)
batch = make([]rsm.Task, 0, taskBatchSize)
entries = make([]sm.Entry, 0, taskBatchSize)
a := make(map[uint64]struct{})
e.processApplies(a, nodes, batch, entries)
count++
if count%200 == 0 {
batch = make([]rsm.Task, 0, taskBatchSize)
entries = make([]sm.Entry, 0, taskBatchSize)
}
case <-e.applyCCIReady.waitCh(workerID):
nodes, cci = e.loadApplyNodes(workerID, cci, nodes)
case <-e.applyWorkReady.waitCh(workerID):
Expand Down

0 comments on commit 9d429ab

Please sign in to comment.