Bug 390463

Summary: Filter lags in 4.n versions
Product: [Applications] krita Reporter: acc4commissions
Component: FiltersAssignee: Dmitry Kazakov <dimula73>
Status: RESOLVED FIXED    
Severity: normal CC: halla, rjquiralte
Priority: NOR Keywords: regression, release_blocker, triaged
Version: 4.0.0-beta.1   
Target Milestone: ---   
Platform: Other   
OS: Microsoft Windows   
Latest Commit: Version Fixed In:
Attachments: Callgrind logs

Description acc4commissions 2018-02-14 16:48:02 UTC
https://forum.kde.org/viewtopic.php?f=281&t=151075

https://www.youtube.com/watch?v=yB94VMhjszU

Krita 4.0 (including beta, nightlies) shows slow performance on overall filters. And it's especially obvious when applying some filters like 'Color to Alpha','Gradient Map' to a large image. If the image is larger than around 3k, 4.0 freezes.

*
Krita 3.3.3 does a fine job.

*
The applying process seems to be eventually completed if you wait a long time, but undoing it causes same freeze if the image is big enough. (Undo works fine on smaller images)
Comment 1 Halla Rempt 2018-02-15 08:58:24 UTC
There certainly is a difference, though for me it's not as pronounced as reported.
Comment 2 Halla Rempt 2018-02-15 10:01:41 UTC
* If I disable progress reporting in Settings, 4.0 is much faster
* But that doesn't show up in the callgrind logs, where 3.3 is mostly busy in the filter itself, 4.0 seems to be mostly busy in the lod and multithreading mechanism.
Comment 3 Halla Rempt 2018-02-15 10:03:09 UTC
Created attachment 110682 [details]
Callgrind logs

Started callgrind the moment the image was fully loaded. Opened the gradient map filter, selected another gradient, waited until the preview was done, then press ok. When the image was updated, callgrind was disabled and a dump made.
Comment 4 acc4commissions 2018-02-15 19:32:48 UTC
Thanks for checking. 
But disabling progress reporting doesn't seem to make any noticeable difference here. It takes almost exact same amount of time to process same image.
Comment 5 Dmitry Kazakov 2018-02-28 13:17:27 UTC
Yes, Color to Alpha filter is extremely slow here. And disabling progress reporting doesn't help (which disables only reporting in the statusbar only, not in the layers docker). The bug is seen much better when instant preview is disabled.
Comment 6 Quiralta 2018-02-28 17:06:43 UTC
I always thought this issue was related to https://bugs.kde.org/show_bug.cgi?id=372221 thinking it was a side effect of using the new color selector, a least I've been experiencing this delay since, filters like color to alpha where instantaneous previously, as for now it takes close to a minute to produce the effect.
Comment 7 Halla Rempt 2018-02-28 17:13:39 UTC
No, it's completely unrelated.
Comment 8 Dmitry Kazakov 2018-03-01 15:08:56 UTC
Git commit 907f88b9445e32425ddf384e4c99815b853bf680 by Dmitry Kazakov.
Committed on 01/03/2018 at 15:07.
Pushed by dkazakov into branch 'master'.

Fix filters slowdown due to progress reporting

Now we have a special type of a sequential iterator
(KisSequentialIteratorProgress), which can also handle
progress reporting (report on every new line).

This patch also refactors a few filters to use sequential
iterator and support multithreading/instant preview.

A  +55   -0    libs/image/KisSequentialIteratorProgress.h     [License: GPL (v2+)]
M  +3    -10   libs/image/filter/kis_color_transformation_filter.cc
M  +11   -0    libs/image/filter/kis_filter.cc
M  +2    -9    libs/image/kis_gradient_painter.cc
M  +1    -10   libs/image/kis_lod_transform.h
M  +5    -2    libs/image/kis_progress_update_helper.h
M  +31   -2    libs/image/kis_sequential_iterator.h
M  +5    -4    libs/image/krita_utils.cpp
M  +41   -0    libs/image/tests/kis_iterators_ng_test.cpp
M  +2    -0    libs/image/tests/kis_iterators_ng_test.h
M  +7    -4    libs/widgetutils/KoUpdater.cpp
M  +10   -13   plugins/filters/colors/kis_color_to_alpha.cpp
M  +4    -13   plugins/filters/colors/kis_minmax_filters.cpp
M  +3    -9    plugins/filters/colorsfilters/colorsfilters.cpp
M  +3    -7    plugins/filters/embossfilter/kis_emboss_filter.cpp
M  +33   -36   plugins/filters/fastcolortransfer/fastcolortransfer.cpp
M  +2    -9    plugins/filters/gradientmap/krita_filter_gradient_map.cpp
M  +11   -28   plugins/filters/imageenhancement/kis_simple_noise_reducer.cpp
M  +18   -21   plugins/filters/imageenhancement/kis_wavelet_noise_reduction.cpp
M  +7    -13   plugins/filters/noisefilter/noisefilter.cpp
M  +9    -26   plugins/filters/oilpaintfilter/kis_oilpaint_filter.cpp
M  +1    -1    plugins/filters/oilpaintfilter/kis_oilpaint_filter.h
M  +63   -43   plugins/filters/pixelizefilter/kis_pixelize_filter.cpp
M  +3    -0    plugins/filters/pixelizefilter/kis_pixelize_filter.h
M  +12   -18   plugins/filters/raindropsfilter/kis_raindrops_filter.cpp
M  +7    -7    plugins/filters/randompickfilter/randompickfilter.cpp
M  +1    -0    plugins/filters/randompickfilter/randompickfilter.h
M  +65   -49   plugins/filters/roundcorners/kis_round_corners_filter.cpp
M  +4    -11   plugins/filters/threshold/threshold.cpp
M  +46   -57   plugins/filters/unsharp/kis_unsharp_filter.cpp
M  +2    -2    plugins/filters/unsharp/kis_unsharp_filter.h
M  +3    -6    plugins/filters/wavefilter/wavefilter.cpp

https://commits.kde.org/krita/907f88b9445e32425ddf384e4c99815b853bf680