D11828: Simplify orPostingIterator and make it faster

Stefan Brüns noreply at phabricator.kde.org
Sat Mar 31 04:18:49 UTC 2018


bruns created this revision.
bruns added a reviewer: Baloo.
Restricted Application added projects: Frameworks, Baloo.
Restricted Application added a subscriber: Frameworks.
bruns requested review of this revision.

REVISION SUMMARY
  Trivial searches (e.g. baloosearch foo) are expanded to a large list
  of ORed small results sets (e.g. 80 terms with 2...5 entries), thus
  speeding it up is quite beneficial.
  
  Currently, iterators which no longer return any entries are deleted
  and replaced with nullptrs, thus the value has to be checked on each
  iteration. The saved instructions are sufficient to more than amortize
  the cost of moving the remaining elements in the vector.
  
  The or operator has to return the smallest ID of the combined sets.
  Instead of doing a traversal on each next() call, determine the smallest
  ID on the first call and update it when checking if the iterators have
  to be advanced.
  
  Keep the docId in a local variable, as the virtual function call to
  (PostingIterator*)->docId() is somewhat expensive.
  
  According to valgrind, typical execution cost of Baloo::Query::exec()
  is reduced by 25% to 40%.
  
  Signed-off-by: Stefan Brüns <stefan.bruens at rwth-aachen.de>

TEST PLAN
  valgrind --tool=callgrind baloosearch foo OR bar

REPOSITORY
  R293 Baloo

BRANCH
  speedup_orpostingoperator

REVISION DETAIL
  https://phabricator.kde.org/D11828

AFFECTED FILES
  src/engine/orpostingiterator.cpp
  src/engine/orpostingiterator.h

To: bruns, #baloo
Cc: #frameworks, ashaposhnikov, michaelh, astippich, spoorun, ngraham, alexeymin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20180331/5996b0a9/attachment.html>


More information about the Kde-frameworks-devel mailing list