Hi,
I'm using bleve full text search, which uses couchbase as backend. Sometimes I observe high CPU consumption taking several minutes, sometimes even golang garbage collector cannot operate. Tracking the issue down pointed to FSTIterator.next method.
There are around ~400.000 items in the statesStack in my instance. All represents linear sequence of nodes (NumTransitions() == 1 for whole list). There was an optimization made by @steveyen in 462e86d which cuts linear sequence of nodes and spares OUTER loop. But it does not do so when all nodes are in linear sequence. Here is the code:
// if the top of the stack represents a linear chain of states
// (i.e., a suffix of nodes linked by single transitions),
// then optimize by popping the suffix in one shot without
// going back all the way to the OUTER loop
var popNum int
for j := len(i.statesStack) - 1; j > 0; j-- {
if i.statesStack[j].NumTransitions() != 1 {
popNum = len(i.statesStack) - 1 - j
break
}
}
if popNum < 1 { // always pop at least 1 entry from the stacks
popNum = 1
}
When all nodes are in linear sequence, popNum remains zero and is set to 1 after the cycle. In my opinion the condition is there for the case the stack top would have more transitions, but when all have 1, it causes looping.
Is it a bug in optimization or is it by intent?
Thanks for reviewing
Hi,
I'm using bleve full text search, which uses couchbase as backend. Sometimes I observe high CPU consumption taking several minutes, sometimes even golang garbage collector cannot operate. Tracking the issue down pointed to FSTIterator.next method.
There are around ~400.000 items in the
statesStackin my instance. All represents linear sequence of nodes (NumTransitions() == 1for whole list). There was an optimization made by @steveyen in 462e86d which cuts linear sequence of nodes and spares OUTER loop. But it does not do so when all nodes are in linear sequence. Here is the code:When all nodes are in linear sequence,
popNumremains zero and is set to 1 after the cycle. In my opinion the condition is there for the case the stack top would have more transitions, but when all have 1, it causes looping.Is it a bug in optimization or is it by intent?
Thanks for reviewing