<table><tr><td style="">bruns created this revision.<br />bruns added a reviewer: Baloo.<br />Restricted Application added projects: Frameworks, Baloo.<br />Restricted Application added a subscriber: Frameworks.<br />bruns requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D11828">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>Trivial searches (e.g. baloosearch foo) are expanded to a large list<br />
of ORed small results sets (e.g. 80 terms with 2...5 entries), thus<br />
speeding it up is quite beneficial.</p>

<p>Currently, iterators which no longer return any entries are deleted<br />
and replaced with nullptrs, thus the value has to be checked on each<br />
iteration. The saved instructions are sufficient to more than amortize<br />
the cost of moving the remaining elements in the vector.</p>

<p>The or operator has to return the smallest ID of the combined sets.<br />
Instead of doing a traversal on each next() call, determine the smallest<br />
ID on the first call and update it when checking if the iterators have<br />
to be advanced.</p>

<p>Keep the docId in a local variable, as the virtual function call to<br />
(PostingIterator*)->docId() is somewhat expensive.</p>

<p>According to valgrind, typical execution cost of Baloo::Query::exec()<br />
is reduced by 25% to 40%.</p>

<p>Signed-off-by: Stefan BrĂ¼ns <stefan.bruens@rwth-aachen.de></p></div></div><br /><div><strong>TEST PLAN</strong><div><p>valgrind --tool=callgrind baloosearch foo OR bar</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R293 Baloo</div></div></div><br /><div><strong>BRANCH</strong><div><div>speedup_orpostingoperator</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D11828">https://phabricator.kde.org/D11828</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>src/engine/orpostingiterator.cpp<br />
src/engine/orpostingiterator.h</div></div></div><br /><div><strong>To: </strong>bruns, Baloo<br /><strong>Cc: </strong>Frameworks, ashaposhnikov, michaelh, astippich, spoorun, ngraham, alexeymin<br /></div>