SearchJob: don't assemble OR term recursively
ClosedPublic

Authored by dvratil on Apr 18 2020, 2:51 PM.

Details

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.

Diff Detail

Repository
R177 PIM: KIMAP
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dvratil created this revision.Apr 18 2020, 2:51 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 18 2020, 2:51 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
dvratil requested review of this revision.Apr 18 2020, 2:51 PM
vkrause accepted this revision.Apr 19 2020, 8:43 AM
This revision is now accepted and ready to land.Apr 19 2020, 8:43 AM
This revision was automatically updated to reflect the committed changes.