Bug 388545 - Transform mask isn't multi-threaded
Summary: Transform mask isn't multi-threaded
Status: REPORTED
Alias: None
Product: krita
Classification: Applications
Component: General (show other bugs)
Version: 4.0 pre-alpha
Platform: Microsoft Windows Microsoft Windows
: NOR wishlist
Target Milestone: ---
Assignee: Krita Bugs
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-01-04 22:20 UTC by Alex
Modified: 2018-01-05 13:05 UTC (History)
2 users (show)

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


Attachments
Natron simple resize node setup (29.11 KB, application/vnd.natron.project)
2018-01-05 12:17 UTC, Alex
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Alex 2018-01-04 22:20:46 UTC
Currently it seems to be single threaded. To replicate:
- create new document like 4000x4000
- paste any smaller picture, something like 2000x2000
- apply transform mask to new layer
- use transform tool to scale down layer, to e.g. 10%
- it will take a while, look @ krita usage, here only 1 CPU is used
Sometimes something weird happens and layer isn't displayed, you need to turn it off and on again.
After layer appears CPU is still used for a while and layer is "smoothed". This is also single-threded.
Comment 1 wolthera 2018-01-04 22:27:41 UTC
How do you know it "could" be multithreaded? That sounds like you have a plan on how to multithread it?

Because as far as I know the problem with layers and transforms is that it is too difficult to subdivide the transformation of a single layer into multiple tasks and then get back something that can be patched together again...
Comment 2 Alex 2018-01-04 22:36:51 UTC
No, I don't have plan, just noticed this as it was taking pretty long. I was not aware of the problem here, sorry. Is title now ok?
Comment 3 Alex 2018-01-05 12:17:32 UTC
Created attachment 109691 [details]
Natron simple resize node setup

I've done little research regarding this and tested ImageMagick, GMIC, PS and Natron. I was using this photo to test:
https://static.pexels.com/photos/770526/pexels-photo-770526.jpeg

IM:
convert test.jpg -filter Cubic -resize 300% out.jpg
GMIC:
gmic test.jpg -resize 300%,300%,100%,100%,5 output out.jpg
PS:
open and resize 300%
Natron:
Read node -> Resize node with scale 3 and cubic filter -> Viewer node, GPU rendering disabled and display clip disabled and zoomed to 100%

IM indeed is using only 1 cpu and it takes about 23 seconds.
GMIC seems to use all cpus and it takes about 9 seconds with cubic and 2 seconds with nearest-neighbor interpolation (just -resize 300%,300% in command line)
PS: about 3 seconds with cubic interpolation

and... Natron: about 2 seconds with 8 threads set and about 5 seconds with 1 thread set inside options so it's both really, really fast and multi-threaded.

I couldn't test Krita as it limits image resize to 10000px, but maybe some code from Natron can be used:
https://github.com/MrKepzie/Natron
I couldn't find resize node specific code though...
Comment 4 Halla Rempt 2018-01-05 12:35:11 UTC
Natron actually doesn't resize the image; it calculates a transformed version of the image that fits in the viewport from the original image -- that's what you get with a node editor. It has no bearing on what an pplication like Krita or Gimp does.
Comment 5 Alex 2018-01-05 13:05:38 UTC
Indeed you are right, I forgot that I should have rendered image not only make preview! Moreover seems I've not zoomed to 100% anyway, doh, nvm.

Timings with final render are:
32 seconds with 1 thread
10 seconds with 8 thread (cpu really to 100%)

So it's about same as GMIC.
Hope this findings can be useful anyway.