st3w / neo

Simulates the digital rain from "The Matrix" (CMatrix clone with 32-bit color and Unicode support)
Other
667 stars 25 forks source link

Slowdown in fullscreen macos #14

Closed Reaster0 closed 2 years ago

Reaster0 commented 2 years ago

aaaand when a issue is closed, another is open

so i bring you once again a new bug

when i lauch neo and i put the cli in fullscreen (or in a big window), there is a slowdown that happen ~15s after the launch of the program, like it has really some difficulties to draw characters and it goes worse and worse

i notice that the program take 100% of the global cpu capacity, so it's clearly a performance issue, do you think it's a ncurses bottleneck or there is a small recursive function that goes wild somewhere and that's why the performances and worse and worse? (i don't let the program run for too long in case it may freeze my pc but clearly it make some part of my os laggy)

st3w commented 2 years ago

Nooooooooooooooooooooooooooooooooooooooooo

Does this issue happen with more than one terminal emulator? I have done stability testing of neo hours, even days, and have never seen something like this :(

It shouldn't be possible for neo to use 100% of all CPU cores because it is single threaded. I could maybe see why it would be 100% on 1-3 cores (one for neo, another for the terminal, still another for the window manager).

There is no recursion in neo. I also deliberately designed it to avoid reallocating memory at runtime as much as I could to avoid stuttering, memory fragmentation, etc.

Your version of ncurses (6.2 if I recall correctly) should be rock-solid. That's what I used for development and testing.

Reaster0 commented 2 years ago

yup, still with iterm and classic terminal

yes indeed I misspoke sorry it seems to take all the perf of one core (not the all cpu X: ) my versions of ncurses is exactly 6.3 there is a screen with a htop on the side, when in this configuration the slowdown is still noticeable but not as much when the whole terminal is in fullscreen

Capture d’écran 2021-12-23 à 00 05 10

again : here is another record so you can see the thing by yourself https://youtu.be/1j4tf95hIbc

st3w commented 2 years ago

Try this command:

neo --fps=20 -d 0.5 --speed=5 --noglitch --colormode=0 --bold=0 --charset=ascii

If it works well, then try removing things one at a time until it starts to break again.

From the htop output, it looks like iTerm is using 100% CPU, but neo is using ~2%. Everything seems to slow down once enough characters appear on the screen. So this seems like a bug with the terminal or less likely the ncurses library.

Try enabling the GPU renderer in iTerm2 if it isn't already:

https://gitlab.com/gnachman/iterm2/-/wikis/Metal-Renderer

There might be other iTerm2 settings that affect the performance

Reaster0 commented 2 years ago

well after done some testing yes indeed iterm has some options that was in need to be uncheck like : Disable GPU renderer when disconnected from power and Prefer integrated to discrete GPU (i don't know what it does on a m1 but still) BUT STILL i've found a strange case, even if theses options are uncheck, iterm is fully restart, when i'm on battery the issue is still the same, BUT if i'm plugged there is no issues whatsoever, neo run buttersmooth and take way les performance on htop, this is strange because on mac usually the performances are the same plugged and unplugged (and have tested it with a benchmark) so i suppose there is a option in iterm and classic terminal that don't enable something when on battery

well for this time it seems that i'm the issue haha

Reaster0 commented 2 years ago

well i checked today and the issue seems to have disapeared, well it's nice