SearchJob: don't assemble OR term recursively

Authored by dvratil on Apr 20 2020, 10:53 AM.

Description

SearchJob: don't assemble OR term recursively

Summary:
The code was ridiculously inefficient for large OR sets. Trying
to assemble an OR term with 28'000 subterms took minutes and the
process eventually ran out of memory. Instead just use a for loop
and a bit of counting to balance the parentheses, the string
is assembled within milliseconds.

Test Plan:
Added a test to make sure the serialized string is the same as before

A benchmark for 10'000 subterms took 4 seconds. Benchmark for 28'000
subterms got killed by the OOM-killer. After the patch the benchmark
for 28'000 subterms took 2.2 ms.

Reviewers: KDE PIM, vkrause

Reviewed By: KDE PIM, vkrause

Subscribers: kde-pim

Tags: KDE PIM

Differential Revision: https://phabricator.kde.org/D28946

Details

Committed
dvratilApr 20 2020, 10:53 AM
Reviewer
KDE PIM
Differential Revision
D28946: SearchJob: don't assemble OR term recursively
Parents
R177:68facf36edf9: ImapSet: optimize the set before serialization
Branches
Unknown
Tags
Unknown