Orama-Interactive / Pixelorama

Unleash your creativity with Pixelorama, a powerful and accessible open-source pixel art multitool. Whether you want to create sprites, tiles, animations, or just express yourself in the language of pixel art, this software will realize your pixel-perfect dreams with a vast toolbox of features. Available on Windows, Linux, macOS and the Web!
https://orama-interactive.itch.io/pixelorama
MIT License
7.18k stars 384 forks source link

High CPU Usage #85

Open Martin1991zab opened 4 years ago

Martin1991zab commented 4 years ago

Hello,

i notified that the Pixelorama eats 2 cpu cores while in idle completely.

I have a laptop with Intel Core i7 7600U (2 Cores - 4 Threads) running Fedora 31. Pixelorama is permanently at 50-60% in htop, for comparison the godot editor at only 5%.

Calinou commented 4 years ago

This is due to Pixelorama not using low-processor usage mode. We could enable it, but something in the project is causing Pixelorama to redraw constantly while it's enabled (likely something in _process). We need to fix this before we can benefit from the low-processor usage mode setting.

OverloadedOrama commented 4 years ago

So the cause of this might be that update() (which is used to update the _draw() method in CanvasItem objects) is called in _process()? I could try and optimize this if this is the case.

Calinou commented 4 years ago

@OverloadedOrama That could be it. Try to enable low processor usage mode in the Project Settings and monitor the CPU usage while Pixelorama is running. Maybe an update spinner could be implemented for debugging purposes (like we have in the Godot editor).

OverloadedOrama commented 4 years ago

I enabled it in c840bed941cfb73beb16a6568abfd5abdf17be55. I think I notice less CPU usage now, but the difference is not very big. Might make a bigger difference on low-end software though.

Martin1991zab commented 4 years ago

Well yes ... roughly 5% less with my laptop, but still 45% - 50% in idle. When i start to paint something we have 60% again. Tested with: d3ff1e984b20d403fe1f4fbc0035311f6b61d08c

OverloadedOrama commented 4 years ago

Hmm I see... I'll try optimizing how often _draw() methods are being called then, at some point.

OverloadedOrama commented 4 years ago

CPU usage should be less now when idle, since update() methods aren't being called all the time, in Canvas.gd in 3a20b3e073339c49ab2e7cfcdcfe7541cb2bf755 and the rulers in 037a797afc7fdc4e6a3a2d6f74a49ec1f584d732. The canvas could use a few more optimizations however, because it's being re-drawn every time it detects input.

Martin1991zab commented 4 years ago

Tested with: 61169f86bab6e70a7a178d37725326efb46f5078 on Godot master (f90e8c41) Result: down to 40-45% on Godot beta - idle and drawing

Martin1991zab commented 4 years ago

080676ac8342b63a47088ec2231ef513f157a882 is not really a change

it seams like the canvas is not that big problem. is set a print in the draw function:

grafik

As long as i understand it correct, the canvas is now drawn much less. I also looked at the _input function after the InputEventMouse check how often it runs, but it looks much like the _draw function. So i think the problem is somewhere else. (or i still misunderstand something because i am fairly new to the godot stuff)

Martin1991zab commented 4 years ago

By the way: Is there a way to profile a game/ program down to single function calls or lines? Like the NYTProf for Perl 5? https://metacpan.org/pod/Devel::NYTProf

(Screenshots stolen) grafik grafik

OverloadedOrama commented 4 years ago

Godot does have a Profiler on the bottom side under Debugger, and then at the Profiler tab. But I've only used it a couple of times and I'm not sure if it's as advanced as the example you provided.

Calinou commented 4 years ago

Godot only provides per-method profiling with inclusive and self times, not per-line profiling or flamegraphs.

Martin1991zab commented 4 years ago

hm, ok, sad but i understand. i think i might be open a feature request (or so) for this - or implement it my self - at least writing out the needed information would be helpful Topic "Profiler" end. Thanks.

Martin1991zab commented 4 years ago

hi,

last test result on 52ea30f5ee18f94464bbbc8cab594165c136a7b1 with godot beta:

looks good :smiley:

OverloadedOrama commented 4 years ago

@Martin1991zab Awesome! Should we close the issue then?

Martin1991zab commented 4 years ago

I am not sure.

The original problem is solved: the cpu fan don't mutate to a jet engine in idle any more, on the other hand the cpu usage while drawing is still strange and should be considered in the future ...

So, because of that, i would let you decide how to handle this "to close or not to close"

Rakeshlal791 commented 4 years ago

Hello, today I learned about this application and downloaded the Linux release. I have noticed this performance issue too. Whenever I perform any action on the Canvas the application starts to lag. And soon it becomes almost unfit for work. I think the undo/redo stack is faulty. On a low spec PC like mine the lag is clearly noticeable.

Calinou commented 4 years ago

@rakeshlal-dev What's your PC specs (CPU, graphics card, …)?

Rakeshlal791 commented 4 years ago

I have Intel i3, dual core, 2.2 GHZ, x86_64 arch CPU with 6 GB RAM. Graphics card is Intel HD 3000. I am using Kubuntu (KDE+Ubuntu) OS.

yuyutsupoudel commented 4 years ago

Im not experiencing lag for small canvas but pixelorama still takes around 15-17% while idle and 17-20% while drawing. If I try to draw on large canvas, well it lags a lot even though cpu usage never goes more than 25% edit: i3 3rd gen @ 2.4 Ghz with 2C4T

yuyutsupoudel commented 3 years ago

Man this issue is really bugging me. It is possible to lower cpu usage even more? I dont notice generally but if i have pixelorama ane godot both open, i notice quite a few shuttering.

OverloadedOrama commented 3 years ago

@yuyutsupoudel In version 0.8.3 which is coming out in a few days, you will be able to lower the application's FPS which reduces CPU usage. Of course, we will do our best to keep optimizing the software.

yuyutsupoudel commented 3 years ago

@yuyutsupoudel In version 0.8.3 which is coming out in a few days, you will be able to lower the application's FPS which reduces CPU usage. Of course, we will do our best to keep optimizing the software.

@OverloadedOrama its not that big of issue while using application. Its just that computer lags a lot while having two three instance of pixelorama in background. Is it possible to have a option to disable performance heavy feature of pixelorama when it looses focus?

OverloadedOrama commented 3 years ago

Yes, this option will be available in v0.8.3 too, from the Preferences.