Summary: | Switching calendar views takes more than 20 seconds eating 100% CPU | ||
---|---|---|---|
Product: | [Applications] korganizer | Reporter: | Eduardo Habkost <ehabkost> |
Component: | general | Assignee: | kdepim bugs <kdepim-bugs> |
Status: | RESOLVED FIXED | ||
Severity: | normal | CC: | kde-2011.08, smartins, tom_t |
Priority: | NOR | ||
Version: | unspecified | ||
Target Milestone: | --- | ||
Platform: | Compiled Sources | ||
OS: | Linux | ||
Latest Commit: | Version Fixed In: | ||
Sentry Crash Report: | |||
Attachments: | Patch to speed up size calculation of rich text delegate |
Description
Eduardo Habkost
2008-09-13 18:34:19 UTC
I've noticed reloadTodos() is being called twice because there are two TodoView objects, so it is expected anyway. The interesting part is: the first reloadTodos() is "quick": it takes two seconds to complete. The second reloadTodos() call is the one that takes almost 20 seconds. However, both are emitting 1539 dataChanged signals. Completing the backtrace I've sent previously, this is the continuation of the call path to the reloadTodos() call that is taking longer: #23 0x010a7c37 in KOTodoModel::reloadTodos (this=0x9d91228) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/views/todoview/kotodomodel.cpp:258 #24 0x010b11fe in KOTodoView::updateView (this=0x9dc6f68) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/views/todoview/kotodoview.cpp:346 #25 0x010d60c2 in KOViewManager::updateView (this=0x9ba14e8, start=@0xa5d1dac, end=@0xa5d1dc4) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/koviewmanager.cpp:197 #26 0x010cc27a in CalendarView::updateView (this=0x9ba0fb8, start=@0xa5d1dac, end=@0xa5d1dc4) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/calendarview.cpp:795 #27 0x010cc2e3 in CalendarView::showDates (this=0x9ba0fb8, selectedDates=@0x9ae3518) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/calendarview.cpp:1653 #28 0x010d1cba in CalendarView::qt_metacall (this=0x9ba0fb8, _c=QMetaObject::InvokeMetaMethod, _id=175, _a=0xbfc1d2ec) (Yes, I have more than 1500 TODO items on my calendar. I keep them around, as a history of the tasks I've completed in the past. I usually set up filters to hide the completed items, so I don't see all of them. 8) Created attachment 28566 [details]
Patch to speed up size calculation of rich text delegate
This patch speeds up the calculation of the size hint for rich text delegates by introducing a new QTextDocument member variable which avoids creating a temporary QTextDocument for each call of sizeHint().
Eduardo, would you mind to test it to see if it improves performance? The patch should be applied in korganizer/views/todoview.
Further information: reloadTodo() is called twice, because there are two todo views around in KOrganizer. The first one is the big on in the main window, the second one the small one in the sidepane. I guess the small one is hidden in your case, so Qt manages to avoid calling sizeHint() for hidden columns / views. Another point is that the todo view should in theory almost never be forced to reload itself, as it should adapt incrementally to all changes in the calendar. However, I couldn't manage to get rid of the call to reloadTodos() in KOTodoView::updateView(), because otherwise the view wont load at all. I tried to reload the view only when setCalendar() is called, but apparently this method is called before items get added to the calendar. Furthermore, during initialisation of the calendar no change signals are emitted, so the todoview can't change one todo after the other. I think there is a problem somewhere else, but as Akonadi is around the corner, which will change the way todos (and anything else) are loaded completely, I guess the only thing I could do regarding this bug is the already attached patch. Anyway, thanks a lot for your detailed analysis. Thomas It seems that this issue has been known since August in Ubuntu: https://bugs.launchpad.net/ubuntu/+source/kdepim/+bug/258611 It has been confirmed by several people there, myself included (OP). (In reply to comment #2) > Created an attachment (id=28566) [details] > Patch to speed up size calculation of rich text delegate > > This patch speeds up the calculation of the size hint for rich text delegates > by introducing a new QTextDocument member variable which avoids creating a > temporary QTextDocument for each call of sizeHint(). > Eduardo, would you mind to test it to see if it improves performance? The patch > should be applied in korganizer/views/todoview. Hi, Sorry for taking so long to reply. I've tested the patch and the situation improved, but it is not perfect yet. Now instead of taking up to 40 seconds, it takes around 1.6 seconds on the first reloadTodos() call, and around 12 seconds on the second reloadTodos() call. I've seen it spending time destroying QTextObject objects on the loop (see backtrace below), but I didn't profile it (yet) to check if this is really the main place where it is eating CPU, now. #0 0x06bdc6a4 in QObjectPrivate::removePendingChildInsertedEvents () from /usr/lib/libQtCore.so.4 #1 0x03cb9f2f in QApplication::notify () from /usr/lib/libQtGui.so.4 #2 0x0032492f in KApplication::notify (this=0xbfe7aae4, receiver=0x960bfe0, event=0xbfe78f18) at /mnt/common/code/kde/svn/trunk/KDE/kdelibs/kdeui/kernel/kapplication.cpp:307 #3 0x06bce2f1 in QCoreApplication::notifyInternal () from /usr/lib/libQtCore.so.4 #4 0x06be5fae in QCoreApplication::sendEvent () from /usr/lib/libQtCore.so.4 #5 0x06bdcb64 in QObjectPrivate::setParent_helper () from /usr/lib/libQtCore.so.4 #6 0x06be5208 in QObject::~QObject () from /usr/lib/libQtCore.so.4 #7 0x03ecdbd8 in QTextObject::~QTextObject () from /usr/lib/libQtGui.so.4 #8 0x03ecdc22 in QTextFrame::~QTextFrame () from /usr/lib/libQtGui.so.4 #9 0x03ee5d8b in ?? () from /usr/lib/libQtGui.so.4 #10 0x03ed5542 in QTextDocument::setHtml () from /usr/lib/libQtGui.so.4 #11 0x0089ef3c in KOTodoRichTextDelegate::sizeHint (this=0x8dc0e40, option=@0xbfe79234, index=@0xbfe792b4) at /mnt/common/code/kde/svn/trunk/KDE/kdepim/korganizer/views/todoview/kotododelegates.cpp:467 If someone attaches/makes an example resource file, I can have a look at the problem. SVN commit 903450 by smartins: Thomas Thrainer's patch to speed up size calculation of rich text delegate. CCBUG: 170993 M +6 -7 kotododelegates.cpp M +3 -0 kotododelegates.h WebSVN link: http://websvn.kde.org/?view=rev&revision=903450 SVN commit 903468 by smartins: Don't call mTodoList->updateView() when switching between agenda/monthview. CCBUG: 170993 M +5 -3 calendarview.cpp M +1 -1 calendarview.h WebSVN link: http://websvn.kde.org/?view=rev&revision=903468 Eduardo, can you update your trunk and try again? Thanks I cannot reproduce in current Trunk. The problem seems fixed. |