Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU leak in ringboard-egui #45

Closed
vi opened this issue Feb 13, 2025 · 6 comments
Closed

CPU leak in ringboard-egui #45

vi opened this issue Feb 13, 2025 · 6 comments

Comments

@vi
Copy link

vi commented Feb 13, 2025

Idling ringboard-egui consumes considerable CPU time.

strace shows significant syscall activity:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 23.78    0.014925           4      3704      1589 recvmsg
 22.49    0.014117           3      4161           poll
 21.02    0.013197           4      2706        10 ioctl
 17.38    0.010912           5      2142           writev
  3.35    0.002101           2       918           getpid
  2.95    0.001854           7       258           epoll_wait
  2.94    0.001848           3       516           epoll_ctl
  2.69    0.001691           4       411       258 read
  1.85    0.001159           3       307           write
  1.49    0.000935           3       258           timerfd_settime
  0.06    0.000036          18         2           mmap
  0.00    0.000000           0         2           munmap
------ ----------- ----------- --------- --------- ----------------
100.00    0.062775           4     15385      1857 total

When inactive, I expected it to just wait on read from inotify for the trigger file, not poll something again and again.

@SUPERCILEX
Copy link
Owner

Ah yeah that's a known bug somewhere in winit/x11 I think. What's your DE echo $XDG_CURRENT_DESKTOP? You can avoid the bug by running XDG_CURRENT_DESKTOP=i3 cargo +nightly install clipboard-history-egui --no-default-features --features $XDG_SESSION_TYPE --force which compiles out the problematic code:

ctx.send_viewport_cmd(ViewportCommand::Visible(false));

@vi
Copy link
Author

vi commented Feb 14, 2025

Desktop is i3, but XDG_CURRENT_DESKTOP is typically empty.

Setting it to i3 for ringboard-egui does not seem to change things - still constant 1% cpu and the same syscalls.

@SUPERCILEX
Copy link
Owner

Did you killall ringboard-egui? Won't have picked up the change otherwise.

@SUPERCILEX
Copy link
Owner

See 1b3cdd8

@vi
Copy link
Author

vi commented Feb 14, 2025

Built from commit 1b3cdd8.

With RINGBOARD_NO_DAEMON, the process exits when I close the window.

But without RINGBOARD_NO_DAEMON (i.e. the default mode), it still consumes CPU. Activity displayed by strace surge when I move mouse.

$ pgrep ringboard-egui
5640

(without mouse moving):
$ timelimit -t 5 strace -cfp 5640
...
(15 threads attached. Why so many?)
...
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 23.59    0.003482           3      1020       440 recvmsg
 21.89    0.003231           4       674         1 ioctl
 19.97    0.002948           2      1139           poll
 16.35    0.002413           4       588           writev
  3.81    0.000563           2       252           getpid
  3.74    0.000552           3       147           epoll_ctl
  3.51    0.000518           7        73           epoll_wait
  3.14    0.000464           4       115        73 read
  1.97    0.000291           3        74           timerfd_settime
  1.92    0.000283           3        84           write
  0.10    0.000015          15         1           munmap
------ ----------- ----------- --------- --------- ----------------
100.00    0.014760           3      4167       514 total

(now with moving mouse:)
$ timelimit -t 5 strace -cfp 5640
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 26.50    0.032734           3      9336           poll
 25.82    0.031889           4      7719      2350 recvmsg
 20.89    0.025802           5      4884         2 ioctl
 15.43    0.019059           4      4222           writev
  4.07    0.005029           2      1852           write
  3.38    0.004170           2      1808           getpid
  1.24    0.001530           2       602       301 read
  1.21    0.001500           2       602           epoll_ctl
  0.73    0.000899           2       301           timerfd_settime
  0.69    0.000847           2       301           epoll_wait
  0.03    0.000038          38         1           mmap
  0.01    0.000012          12         1           munmap
------ ----------- ----------- --------- --------- ----------------
100.00    0.123509           3     31629      2653 total

$ tr '\0' '\n' < /proc/5640/environ | rg XDG
XDG_CURRENT_DESKTOP=i3

Note that XDG_CURRENT_DESKTOP is only set specifically for ringboard-egui, not e.g. for rustc that was compiling ringboard-egui, so option_env!("XDG_CURRENT_DESKTOP") is likely None.

@SUPERCILEX
Copy link
Owner

Ah well yeah you need actually have XDG_CURRENT_DESKTOP set by the time you compile.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants