[clangd] Improve performance of dex by 45-60%
authorKirill Bobyrev <kbobyrev@google.com>
Fri, 23 Jul 2021 13:28:31 +0000 (15:28 +0200)
committerKirill Bobyrev <kbobyrev@google.com>
Fri, 23 Jul 2021 13:28:35 +0000 (15:28 +0200)
commita0987e350ccce4fb9c3cbaf56732be1def5f810f
tree1d0a143fea093e2df14114bea90069fff0828a3e
parent1528a4d40022925dcc3e8cb6b8af7dd109ad7075
[clangd] Improve performance of dex by 45-60%

Take full advantage of AND's iterator children size estimation: use early reset
in sync() and prevent large overhead. The idea is that the children at the
beginning of the list are smaller and cheaper to advance. Very large children
negate the effect of this performance optimisation and hence should be
advanced only when absolutely necessary. By reducing the number of large
iterators' updates, we increase the performance by a large margin.

This change was tested on a comprehensive query dataset. The performance
boost increases with the average length of the query, on small queries it is
close to 45% but the longer they go the closer it gets to 60% and beyond.

Reviewed By: sammccall

Differential Revision: https://reviews.llvm.org/D106528
clang-tools-extra/clangd/index/dex/Iterator.cpp