ImapSet: optimize the set before serialization
ClosedPublic

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

Details

Summary

Client code usually generates the ImapSet by simply passing it a vector of
IDs or just by calling ImapSet::add() in a for loop for individual IDs. This
creates potentially massive amount of intervals. This change ads a method
that will optimize the ImapSet by merging adjacent or overlapping intervals.

I ran into this trying to move about 28'000 emails to Trash in KMail. The IMAP
resource calls ImapSet::add() in a for loop to add each Item to be moved into
the set. This just created 28'000 single-UID intervals and the resulting request
string was so long that my Courier IMAP server just dropped the connection, so
the IMAP resource reconnected and tried to send the same massive request again
and again and again...

By optimizing the set the string size is reduced from nearly 156 kilobytes
down to less than 4 kilobytes.

Diff Detail

Repository
R177 PIM: KIMAP
Branch
master
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 25420
Build 25438: arc lint + arc unit
dvratil created this revision.Apr 18 2020, 2:33 PM
Restricted Application added a project: KDE PIM. · View Herald TranscriptApr 18 2020, 2:33 PM
Restricted Application added a subscriber: kde-pim. · View Herald Transcript
dvratil requested review of this revision.Apr 18 2020, 2:33 PM
vkrause accepted this revision.Apr 19 2020, 8:40 AM
This revision is now accepted and ready to land.Apr 19 2020, 8:40 AM
This revision was automatically updated to reflect the committed changes.