st icon indicating copy to clipboard operation
st copied to clipboard

CPU 100% when displaying sixel

Open TomJansen opened this issue 6 years ago • 7 comments
trafficstars

When I display a sixel, with for example the command cat image.sixel, the CPU shoots to 100% until I close the st instance. I have also tested displaying a sixel image with mlterm, but here this is not the case. Thanks for this patch btw!

TomJansen avatar Mar 26 '19 11:03 TomJansen

This is the core

[Thread debugging using libthread_db enabled]
Using host libthread_db library "/usr/lib/libthread_db.so.1".
Core was generated by `st'.
#0  0x00007fd9faacf52d in pselect () from /usr/lib/libc.so.6
(gdb) where
#0  0x00007fd9faacf52d in pselect () from /usr/lib/libc.so.6
#1  0x000055a575192144 in run () at x.c:1813
#2  0x000055a575193973 in xinit (rows=<optimized out>, cols=1366772336) at x.c:982
#3  main (argc=0, argv=<optimized out>) at x.c:1977

Sorry if this is not correct. This is my first time debugging a compiled program

TomJansen avatar Mar 26 '19 15:03 TomJansen

I believe the previous core is wrong, this is the right one I believe

(gdb) info threads
  Id   Target Id                              Frame
* 1    Thread 0x7f61bec49780 (LWP 19449) "st" 0x00007f61bf31052d in pselect () from /usr/lib/libc.so.6
(gdb) thread 1
[Switching to thread 1 (Thread 0x7f61bec49780 (LWP 19449))]
#0  0x00007f61bf31052d in pselect () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007f61bf31052d in pselect () from /usr/lib/libc.so.6
#1  0x0000557fc6371273 in run () at x.c:1830
#2  0x0000557fc6372ce7 in main (argc=0, argv=<optimized out>) at x.c:1980

TomJansen avatar Mar 26 '19 16:03 TomJansen

I also want to add in that I've experienced the same issue with a cut-down fork of 0.8.1 with just scrollback and your sixel patches applied. It seems like (as @TomJansen has shown) that almost all of the CPU time is spent in syscall(s).

jpsamaroo avatar Apr 18 '19 15:04 jpsamaroo

~The following pselect() call is returning EPERM consistently while sixels are present:~ This was wrong, but this line is still the start of it, constantly firing: https://github.com/charlesdaniels/st/blob/e6ddd6e7897c22d8a616a4ae55166dfba620e6ec/x.c#L1830

jpsamaroo avatar Apr 18 '19 15:04 jpsamaroo

Sorry, was misinterpreting the return code (noob mistake, I know). The xfd FD is constantly generating events in the loop while sixels are present; I'm still investigating what exactly it's signaling and why.

jpsamaroo avatar Apr 18 '19 16:04 jpsamaroo

Idk why this works, but putting in a call to XPending(xw.dpy) when FD_ISSET(xfd, &rfd) is true seems to stop the insane CPU usage and reduce the number of events per second to reasonable levels.

jpsamaroo avatar Apr 23 '19 15:04 jpsamaroo

Nice. I can confirm that adding XPending(xw.dpy) works. I have not seen any side effect so far

TomJansen avatar Apr 24 '19 12:04 TomJansen