Skip to content
Myr

Increase the number of go routines for search

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Sort performance increases as the size of each sublist decreases (n in nlog(n) decreases). Merger is then responsible for merging the sorted lists in order, and since in most cases we are only interesed in the matches in the first page on the screen so the overhead in the process is negligible.

authored by Junegunn Choi · committed by Junegunn Choi · parent 9352728 · Browse files · 1 file+8 added−7 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+8 added−7 removed

  • other:+8 added−7 removed

1 file+8 added−7 removed

modified:src/matcher.go+8 added-7 removed
41 unmodified lines
42 sort: sort,43 tac: tac,44 eventBox: eventBox,45 reqBox: util.NewEventBox(),46 partitions: runtime.NumCPU(),46 partitions: 16 * runtime.NumCPU(),47 mergerCache: make(map[string]*Merger)}48}4950// Loop puts Matcher in action
54 unmodified lines
105 }106}107108func (m *Matcher) sliceChunks(chunks []*Chunk) [][]*Chunk {109 partitions := m.partitions109 perSlice := len(chunks) / m.partitions110 perSlice := len(chunks) / partitions111111 // No need to parallelize112 if perSlice == 0 {113 return [][]*Chunk{chunks}113 partitions = len(chunks)114 perSlice = 1115 }116116 slices := make([][]*Chunk, m.partitions)117 for i := 0; i < m.partitions; i++ {117 slices := make([][]*Chunk, partitions)118 for i := 0; i < partitions; i++ {119 start := i * perSlice120 end := start + perSlice120 if i == m.partitions-1 {121 if i == partitions-1 {122 end = len(chunks)123 }124 slices[i] = chunks[start:end]125 }
97 unmodified lines