ItemSync: speed up by not using takeFirst().
ClosedPublic

Authored by dfaure on Oct 25 2017, 10:15 AM.

Details

Summary

perf+hotspot shows that this is a horrible algorithm:
http://www.davidfaure.fr/kde/perf_hotspot_itemsync.png

I ported the code to the std::move (the algorithm)

Test Plan

Added a benchmark to itemsynctest.

Before:

RESULT : ItemsyncTest::testFullSyncManyItems():
    368,935,368.19 CPU cycles per iteration (total: 36,893,536,820, iterations: 100)

After:

 RESULT : ItemsyncTest::testFullSyncManyItems():
     349,899,659.49 CPU cycles per iteration (total: 34,989,965,949, iterations: 100)

=> 5% faster (for the whole of ItemSync, which runs much more than this piece of code)

Went down to 346 million after https://commits.kde.org/kcoreaddons/42e1d6e8e7bf7f2738fbe15778b23a84c104e8a8

(Qt + Akonadi built in release-with-debug; KF5 in debug, but not much KF5 code being run here)

Diff Detail

Repository
R165 Akonadi
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
dfaure created this revision.Oct 25 2017, 10:15 AM
Restricted Application added a project: KDE PIM. · View Herald TranscriptOct 25 2017, 10:15 AM
mwolff added a subscriber: mwolff.Oct 25 2017, 1:08 PM

lgtm conceptually, but someone else should check that

Oh and I notice: The patch doesn't include info about the state after - did you measure it and verify that this is indeed faster? I.e. is the move actually happening and everything faster now?

A benchmark would be optimal in such scenarios, of course.

dfaure updated this revision to Diff 21403.Oct 26 2017, 9:31 PM

Now with benchmark, and reserve() added.

dfaure edited the summary of this revision. (Show Details)Oct 27 2017, 7:46 AM
dfaure edited the test plan for this revision. (Show Details)
dvratil accepted this revision.Oct 27 2017, 4:08 PM
This revision is now accepted and ready to land.Oct 27 2017, 4:08 PM
This revision was automatically updated to reflect the committed changes.