Bug 390985 - Krita uses a lot of ram while applying layer styles.
Summary: Krita uses a lot of ram while applying layer styles.
Status: RESOLVED FIXED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 3.3.3
Platform: Microsoft Windows Microsoft Windows
: NOR normal
Target Milestone: ---
Assignee: Dmitry Kazakov
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-02-24 05:47 UTC by Marcelriverosl
Modified: 2018-06-26 15:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments
a project file that uses too much memory when a layer style is applied (70 bytes, text/plain)
2018-02-24 05:57 UTC, Marcelriverosl
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Marcelriverosl 2018-02-24 05:47:33 UTC
Based on just trial and error it seems that layer styles (In this case the stroke) make a simple image use triple the amount of memory in simple seconds.
Comment 1 Marcelriverosl 2018-02-24 05:57:26 UTC
Created attachment 110955 [details]
a project file that uses too much memory when a layer style is applied
Comment 2 Halla Rempt 2018-02-27 10:28:03 UTC
Hm, that doesn't really send memory usage up for me, but let's look into it.
Comment 3 Dmitry Kazakov 2018-02-28 12:51:24 UTC
Well, most probably, the problem is Windows-specific, because its memory allocator is known to be quite inefficient and fragments memory easily.

The real problem is that we use quite inefficient algorithm for calculating "stroke" layers style: instead of using erode/dilate we vectorize the alpha channel and paint a bezier path. This vectorization involves raw memory allocation for selection in KisPixelSelection::outline(), which might cause fragmentation.

We have two solutions for this problem:
1) Implement some caching for KisPixelSelection::outline() buffer
2) Implement caching for KisLayerStyleFilterEnvironment::layerOutlineCache(), which was planned, but never implemented (because of point 3)
3) Use more efficient algorithm for the stroke layer style (erode/dilate), which doesn't need all these buffers.

Boud, what do you think?
Comment 4 Halla Rempt 2018-02-28 12:57:08 UTC
I think we need to do both 1 and 3 -- 1 would also help with other places where the pixel selection outline is used. Though I thought we already had a cache there...
Comment 5 Dmitry Kazakov 2018-06-09 07:43:01 UTC
Git commit 2747016a313d98c137eb5d57229e0112854b70aa by Dmitry Kazakov.
Committed on 09/06/2018 at 07:07.
Pushed by dkazakov into branch 'master'.

Connect Erode/Dilate algorithms to "Stroke" layer style

Now it is **much** faster, more roundish and doesn't eat your memory :)
Related: bug 361130
CC:kimageshop@kde.org

M  +0    -18   libs/image/layerstyles/kis_layer_style_filter_environment.cpp
M  +0    -2    libs/image/layerstyles/kis_layer_style_filter_environment.h
M  +43   -46   libs/image/layerstyles/kis_ls_stroke_filter.cpp

https://commits.kde.org/krita/2747016a313d98c137eb5d57229e0112854b70aa
Comment 6 Dmitry Kazakov 2018-06-09 14:13:05 UTC
Git commit ace6d8252a5a7b783ace53added6584f315ebe1f by Dmitry Kazakov.
Committed on 09/06/2018 at 09:00.
Pushed by dkazakov into branch 'krita/4.0'.

Connect Erode/Dilate algorithms to "Stroke" layer style

Now it is **much** faster, more roundish and doesn't eat your memory :)
Related: bug 361130
CC:kimageshop@kde.org

M  +0    -18   libs/image/layerstyles/kis_layer_style_filter_environment.cpp
M  +0    -2    libs/image/layerstyles/kis_layer_style_filter_environment.h
M  +43   -46   libs/image/layerstyles/kis_ls_stroke_filter.cpp

https://commits.kde.org/krita/ace6d8252a5a7b783ace53added6584f315ebe1f
Comment 7 Andrey 2018-06-26 15:10:45 UTC
Git commit af21ce68e13621dd6a84fd64a767b68e69ec5d2f by Andrey Kamakin, on behalf of Dmitry Kazakov.
Committed on 26/06/2018 at 14:18.
Pushed by akamakin into branch 'akamakin/T8628-multithreading-optimization'.

Connect Erode/Dilate algorithms to "Stroke" layer style

Now it is **much** faster, more roundish and doesn't eat your memory :)
Related: bug 361130
CC:kimageshop@kde.org

M  +0    -18   libs/image/layerstyles/kis_layer_style_filter_environment.cpp
M  +0    -2    libs/image/layerstyles/kis_layer_style_filter_environment.h
M  +43   -46   libs/image/layerstyles/kis_ls_stroke_filter.cpp

https://commits.kde.org/krita/af21ce68e13621dd6a84fd64a767b68e69ec5d2f