kcalc > KCalcButton::paintEvent mallocs more than 80 MB per minute

Joseph P. De Veaugh-Geiss joseph at kde.org
Thu Jun 2 17:51:53 BST 2022


Dear Marius,

thank you very much for being in touch! A specific efficiency 
improvement in a particular piece of software should best be discussed 
with the core developers. You can find contact information for KCalc at 
the following site:

   https://apps.kde.org/kcalc/

That said, please do keep me informed of any progress made and how your 
improvements will contribute to making KDE/FOSS more efficient. We can 
write a post for the KDE Eco blog, for instance, to draw attention to 
the changes.

Also, please make sure to tag any relevant MRs with the "Efficiency" 
tag. This is a useful way for the community to follow what is being done 
in this area and it will be potentially helpful for marketing purposes 
in release notes and the like. You can see efficiency-tagged MRs here:

   https://invent.kde.org/dashboard/merge_requests?label_name[]=Efficiency

Cheers,
Joseph

On 5/30/22 04:35, Marius P wrote:
> Hello,
> 
> Would an improvement for the issue below. Constitute material for the KDE
> Eco initiative?
> If so, I am a senior C++ developer. I do not know Qt. I have more than 2
> hours per week to dedicate to the issue below. I will need help.
> 
> The ideal situation would be to not do custom painting.
> 
> Technical details:
> 
> As per
> https://blogs.gnome.org/chergert/2020/03/15/how-to-use-sysprof-to-part-ii/
> chapter "Reducing Memory Allocations". kcalc in
> https://invent.kde.org/utilities/kcalc/-/blob/master/kcalc_button.cpp#L133
> for each button, does custom painting. mallocs e.g. in QTextDocument ctor
> and in QTextDocument::setHtml(). The button's custom painting method uses
> HTML mainly for center aligning/justifying text.
> 
>      ALLOCATED      TOTAL    FUNCTION
> [   81.1 MiB] [  69.04%]
>   KCalcButton::paintEvent(QPaintEvent*)
> [   23.7 MiB] [  20.20%]
>   QTextDocument::QTextDocument(QObject*)
> [   15.7 MiB] [  13.35%]
>   QTextDocument::setHtml(QString const&)
> [   12.0 MiB] [  10.21%]
>   QTextDocument::size() const
> [   10.3 MiB] [   8.74%]                                        In file
> /usr/lib/x86_64-linux-gnu/qt5/plugins/styles/breeze.so
> [    6.6 MiB] [   5.59%]
>   QTextDocumentLayout::draw(QPainter*,
> QAbstractTextDocumentLayout::PaintContext const&)
> 
> Thanks.
> 

-- 
Joseph P. De Veaugh-Geiss
BE4FOSS Project and Community Manager (KDE Eco)
OpenPGP: 8FC5 4178 DC44 AD55 08E7 DF57 453E 5746 59A6 C06F

---
KDE Eco: Building Energy-Efficient Free Software!

Website: https://eco.kde.org
Mastodon: @BE4FOSS at mastodon.social
Mailing list: 
https://mail.kde.org/cgi-bin/mailman/listinfo/energy-efficiency
Matrix: https://webchat.kde.org/#/room/#energy-efficiency:kde.org
Forum: https://forum.kde.org/viewforum.php?f=334


More information about the Energy-efficiency mailing list