will8211 / unimatrix

Python script to simulate the display from "The Matrix" in terminal. Uses half-width katakana unicode characters by default, but can use custom character sets. Accepts keyboard controls while running. Based on CMatrix.
GNU General Public License v3.0
1.75k stars 161 forks source link

Intense CPU when run unimatrix? #35

Closed tmpm697 closed 3 years ago

tmpm697 commented 3 years ago

I monitor cpu with "watch sensors" and notice cpu core i7 (4 core) has increased at least 6-7 celsius (51,52 to 57,58)

I use unimatrix-git from aur (archlinux) and run "unimatrix -n -l ens -s 96" with "st" terminal.

I also observe less cpu contest with cmatrix than unimatrix.

So what's the problem with unimax? anyway if someone can help to translate "unimatrix -n -l ens -s 96" to cmatrix would be appreciated.

tmpm697 commented 3 years ago

Xorg process go up to 60% cpu while running this software.

And after a while, some other apps get stuck like firefox and I had to manually to kill them.

I have Xorg with rate of 200.

I use 2k monitor dell.

will8211 commented 3 years ago

Could you please add more information:

What terminal emulator are you using?

Are you using any particular command line settings when this happens?

If you start the program and do not use any parameters or keyboard controls, does it happen?

Does it happen consistently on every run? If so, after how long?

On Thu, Jun 10, 2021, 5:04 AM tmpm697 @.***> wrote:

Xorg process go up to 60% cpu while running this software.

And after a while, some other apps get stuck like firefox and I had to manually to kill them.

I use 2k monitor dell.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/will8211/unimatrix/issues/35#issuecomment-858448552, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4WAPJBLSDR45ODCJLI4MDTSB5YTANCNFSM46HB6DJQ .

Apple-Lion commented 3 years ago

Cmatrix is written in c iirc, and as unimatrix is python you sacrifice some speed for ease of reading, changes, and flexibility.

Certainly there are areas of unimatrix that could be improved to the point where there is little to no issues with speed compared to cmatrix; however I think it may be more likely you are experiencing unaccelerated terminal lag.

What OS, what hardware, and what kernel mods do you have loaded for your gpu? If you are using straight out basic VESA, I expect if you are running Linux it is not AMD hardware/gpu or there would be no issue as the kernel would automatically load the proper mods.

Is your gpu nvidia or intel integrated? Are you using Windows with acceleration turned off? Or running unimatrix in a WSL terminal? You stated Arch but you can do some highly interesting things with WSL if you are a masochist.

Cmatrix does not have the flexibility nor the feature set that unimatrix has. I don't think there is a way to do what you ask exactly in cmatrix with its current code base.

will8211 commented 3 years ago

I think the main problem here might be that unimatrix wasn't designed to handle 2k/4k monitors along with high refresh rates like 200 fps.

I'm not sure that much can be done to improve high CPU usage given the current approach using python+ncurses.

I might be wrong, this is just a hypothesis for now.

On Thu, Jun 10, 2021, 9:28 AM Apple-Lion @.***> wrote:

Cmatrix is written in c iirc, and as unimatrix is python you sacrifice some speed for ease of reading, changes, and flexibility.

Certainly there are areas of unimatrix that could be improved to the point where there is little to no issues with speed compared to cmatrix; however I think it may be more likely you are experiencing unaccelerated terminal lag.

What OS, what hardware, and what kernel mods do you have loaded for your gpu? If you are using straight out basic VESA.

I expect if you are running Linux it is not AMD hardware/gpu or there would be no issue as the kernel would automatically load the proper mods.

Is your gpu nvidia or intel integrated? Are you using Windows with acceleration turned off? Or running unimatrix in a WSL terminal?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/will8211/unimatrix/issues/35#issuecomment-858623415, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4WAPOHE72YGB2KNRO6KZLTSC4YFANCNFSM46HB6DJQ .

Apple-Lion commented 3 years ago

Could be. I'm at work so won't be looking it up, but is there not an accelerated terminal project we could test to see if there is a difference in rendering rate?

tmpm697 commented 3 years ago

Step to produce:

  1. start unimatrix as above comment
  2. switch to another tty and check /usr/bin/top
  3. observe /usr/lib/Xorg cpu usage constantly above 30%, wait for a while to 60% and stuck down the OS, os starts to kill apps.

A process that constantly takes up 30% cpu is unusual, especially Xorg in this case.

Check this image: https://imgur.com/gallery/4HsKEk7

tmpm697 commented 3 years ago

Firefox esr (78.11.0esr) crashes when I have both unimatrix and ff running.

https://imgur.com/gallery/WlV2GhC

tmpm697 commented 3 years ago

I use gnome-terminal and sam result, Xorg's cpu and gnome-terminal-server keep over 40% -- so it worse than xst.

will8211 commented 3 years ago

What size is your terminal window? Could you compare your CPU usage at a standard 40x80 terminal to what you're using now?

On Fri, Jun 11, 2021, 6:19 AM tmpm697 @.***> wrote:

I start /usr/bin/X -nolisten tcp "$@" but same result, Xorg keeps over 40%

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/will8211/unimatrix/issues/35#issuecomment-859475418, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC4WAPLRGVOS4L3E2J6CD7LTSHPKFANCNFSM46HB6DJQ .

Apple-Lion commented 3 years ago

Have you tried Alacritty?

https://github.com/alacritty/alacritty

tmpm697 commented 3 years ago

@will8211 I intend to use unimatrix with slock to have it work like matrix lockscreen. So terminal is always at fullscreen - 2k reso

tmpm697 commented 3 years ago

@Apple-Lion I'll install it and try.

tmpm697 commented 3 years ago

Steps: Xst -> unimatrix... -> Xorg 40% Gnome-terminal -> unimatrix... -> Xorg 40% Alacritty -> unimatrix... -> Xorg 0.7% ---> expected

So somehow terminal help in this case, why alacrity does not stress Xorg? But xst and gnome-terminal does?

Apple-Lion commented 3 years ago

This is what I meant by accelerated terminal. Alacritty uses OpenGL to render the terminal. Hence it uses the little 620 dedicated graphics chip on your cpu.

This is better for large resolutions as you can see.

tmpm697 commented 3 years ago

But all text displays in terminal should be able to be rendered by cpu without issue?

This is text, not video or complex 3D objects.

tmpm697 commented 3 years ago

I tested with river and foot|alarcity terminal (pure wayland)

And other tests on Xorg as above.

The total cpu usage in case when I use xst and unimatrix is the lowest 10-15% in total when run both firefox (playing YouTube video) and unimatrix inside terminal.

The only downside of it is intense Xorg cpu usage.

virtadpt commented 3 years ago

I don't know if this helps, but here are a few more data points:

I'm testing right now on a Dell 9570 laptop (Intel i9-8950HK @ 4.8GHz, 32GB RAM (17 GB in use)) running Arch Linux (1 March 2021), kernel 5.11.2-arch1-1, xorg-server 1.20.10-3, Mate Desktop 1.24.1-1, Gnome Terminal 3.30.2, unimatrix-git r66.75f7402-1. It's not even showing up in the output of htop, nor is the Xorg server.

I just upgraded to unimatrix-git-r30.3692561-1. Same thing. If anything, unimatrix is now using a bit less RAM (16.6GB/32 now in use).

tmpm697 commented 3 years ago

@virtadpt I tried with gnome-terminal above and just re-try, same result, Xorg constantly above 40% (note this result from running /usr/bin/top)

I think you used other monitors, not "top".

This stress Xorg and "sensors" command give some plus celsius.

I use the same unimatrix version from aur (arch)

virtadpt commented 3 years ago

Yes, I used htop, not top. I've just repeated the test with regular old top and Firefox and Electron seem to be taking up most of Windbringer's CPU time, with the odd "Web Content" subprocess popping up once in a while.

tmpm697 commented 3 years ago

@virtadpt press "u" and type your username to filter out username's process for better view. Both Xorg and gnome-terminal-server will appear in screen, check CPU column for the info.

Note that, you should start gnome terminal in fullscreen mode before running unimatrix and switch tty and run top in there.

tmpm697 commented 3 years ago

I'm wondering if we can have a way that force idling all processes?

As when run unimatrix as screen locker, I most won't do anything, maybe only allow pulseaudio continues to play background but other apps/processes should be idling.

tmpm697 commented 3 years ago

Suspend and resume tasks would help and I chose to use alacritty for less hustle.