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

libwayland-server 1.18 100% CPU usage #15

Closed
valpackett opened this issue Feb 13, 2020 · 10 comments · Fixed by #16
Closed

libwayland-server 1.18 100% CPU usage #15

valpackett opened this issue Feb 13, 2020 · 10 comments · Fixed by #16

Comments

@valpackett
Copy link

With wayland 1.18 there's a new event loop update that would've fixed the same issue as #8 :D but now there's 100% CPU consumption in wlroots based compositors at least. Here's a dtrace flamegraph, lots of time spent in poll, kevent and ktimer_settime

@jiixyj
Copy link
Owner

jiixyj commented Feb 13, 2020

Hm, maybe one of set_timer/clear_timer here is not correctly implemented yet in the shim... Maybe clear_timer doesn't actually clear the timer, making the event loop spin. I'll try to write a small reproducer.

@jiixyj
Copy link
Owner

jiixyj commented Feb 13, 2020

Found the issue: the new Wayland event loop does not read(2) from the timerfd at all. This is OK if clearing the timerfd with timerfd_settime because all pending events will be deleted. The current implementation in epoll-shim doesn't do this correctly when using the old POSIX per process timer backend. This backend is still used for TFD_TIMER_ABSTIME timerfds.

In the Wayland case we could make it use the faster kqueue/EVFILT_TIMER backend anyway as they always set it_interval of the struct itimerspec to 0. We could also think about using NOTE_ABSTIME.

@zeising
Copy link

zeising commented Feb 14, 2020

Is this a change you want in wayland or in libepoll-shim?

uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 14, 2020
Abi is backward compatible: https://abi-laboratory.pro/tracker/timeline/wayland/
Port changes:
- Allow memfd_create on FreeBSD 13 for sealing
- Drop ms_timeout workaround in favor of upstream fix[1]
- Drop posix_fallocate patch as it was disabled in r455878
- Adjust posix_fallocate comment to improve clarity
- Temporarily revert event loop update until epoll-shim#15 [2] is fixed

[1]: https://gitlab.freedesktop.org/wayland/wayland/commit/75d14834570b
[2]: jiixyj/epoll-shim#15

Build tested on:
    11.3 aarch64
    11.3 amd64
    11.3 armv6
    11.3 i386
    12.0 amd64
    12.0 i386
    12.1 aarch64
    12.1 amd64
    12.1 armv6
    12.1 armv7
    12.1 i386
    13.0 amd64
    13.0 i386
    Base GCC 4.2.1 (mimics powerpc*, mips*, riscv64)

Run tested with:
    multimedia/libva-intel-driver
    multimedia/mpv
    www/firefox + MOZ_ENABLE_WAYLAND
    x11-servers/xwayland-devel
    x11-wm/cage
    x11-wm/sway
    x11/wl-clipboard

PR:  244059
Submitted by: jbeich
Tested by: manu
Reviewed by: manu
Approved by: x11 (bapt)
Differential Revision: https://reviews.freebsd.org/D23643


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@526103 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Feb 14, 2020
Abi is backward compatible: https://abi-laboratory.pro/tracker/timeline/wayland/
Port changes:
- Allow memfd_create on FreeBSD 13 for sealing
- Drop ms_timeout workaround in favor of upstream fix[1]
- Drop posix_fallocate patch as it was disabled in r455878
- Adjust posix_fallocate comment to improve clarity
- Temporarily revert event loop update until epoll-shim#15 [2] is fixed

[1]: https://gitlab.freedesktop.org/wayland/wayland/commit/75d14834570b
[2]: jiixyj/epoll-shim#15

Build tested on:
    11.3 aarch64
    11.3 amd64
    11.3 armv6
    11.3 i386
    12.0 amd64
    12.0 i386
    12.1 aarch64
    12.1 amd64
    12.1 armv6
    12.1 armv7
    12.1 i386
    13.0 amd64
    13.0 i386
    Base GCC 4.2.1 (mimics powerpc*, mips*, riscv64)

Run tested with:
    multimedia/libva-intel-driver
    multimedia/mpv
    www/firefox + MOZ_ENABLE_WAYLAND
    x11-servers/xwayland-devel
    x11-wm/cage
    x11-wm/sway
    x11/wl-clipboard

PR:  244059
Submitted by: jbeich
Tested by: manu
Reviewed by: manu
Approved by: x11 (bapt)
Differential Revision: https://reviews.freebsd.org/D23643
@valpackett
Copy link
Author

@zeising "The current implementation in epoll-shim doesn't do this correctly" should imply that a fix is required here in epoll-shim :)

@zeising
Copy link

zeising commented Feb 14, 2020

@myfreeweb Yeah, I just missed that on the first read-through. Sorry. :(

Jehops pushed a commit to Jehops/freebsd-ports-legacy that referenced this issue Feb 14, 2020
Abi is backward compatible: https://abi-laboratory.pro/tracker/timeline/wayland/
Port changes:
- Allow memfd_create on FreeBSD 13 for sealing
- Drop ms_timeout workaround in favor of upstream fix[1]
- Drop posix_fallocate patch as it was disabled in r455878
- Adjust posix_fallocate comment to improve clarity
- Temporarily revert event loop update until epoll-shim#15 [2] is fixed

[1]: https://gitlab.freedesktop.org/wayland/wayland/commit/75d14834570b
[2]: jiixyj/epoll-shim#15

Build tested on:
    11.3 aarch64
    11.3 amd64
    11.3 armv6
    11.3 i386
    12.0 amd64
    12.0 i386
    12.1 aarch64
    12.1 amd64
    12.1 armv6
    12.1 armv7
    12.1 i386
    13.0 amd64
    13.0 i386
    Base GCC 4.2.1 (mimics powerpc*, mips*, riscv64)

Run tested with:
    multimedia/libva-intel-driver
    multimedia/mpv
    www/firefox + MOZ_ENABLE_WAYLAND
    x11-servers/xwayland-devel
    x11-wm/cage
    x11-wm/sway
    x11/wl-clipboard

PR:  244059
Submitted by: jbeich
Tested by: manu
Reviewed by: manu
Approved by: x11 (bapt)
Differential Revision: https://reviews.freebsd.org/D23643


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@526103 35697150-7ecd-e111-bb59-0022644237b5
@shamazmazum
Copy link

I've also reported this. Maybe in the wrong repo, though

FreeBSDDesktop/epoll-shim#6

jiixyj added a commit that referenced this issue Feb 15, 2020
@jiixyj jiixyj linked a pull request Feb 15, 2020 that will close this issue
@jiixyj
Copy link
Owner

jiixyj commented Feb 16, 2020

Please try PR #16 ! I've thrown out the old POSIX per process timer backend. Now, kqueue EVFILT_TIMER is used exclusively. So no more limit of 32 timerfd's when using TFD_TIMER_ABSTIME.

@jbeich
Copy link
Contributor

jbeich commented Feb 16, 2020

#16 works fine for me: CPU usage is normal after removing workaround. Tested on Sway + Xwayland and xf86-input-libinput on FreeBSD 13.0-CURRENT.

@valpackett
Copy link
Author

Yep, works great for me as well so far! Nice!

@jiixyj
Copy link
Owner

jiixyj commented Feb 22, 2020

This should hopefully be fixed by PR #16, please let me know if I missed something!

svmhdvn pushed a commit to svmhdvn/freebsd-ports that referenced this issue Jan 10, 2024
Abi is backward compatible: https://abi-laboratory.pro/tracker/timeline/wayland/
Port changes:
- Allow memfd_create on FreeBSD 13 for sealing
- Drop ms_timeout workaround in favor of upstream fix[1]
- Drop posix_fallocate patch as it was disabled in r455878
- Adjust posix_fallocate comment to improve clarity
- Temporarily revert event loop update until epoll-shim#15 [2] is fixed

[1]: https://gitlab.freedesktop.org/wayland/wayland/commit/75d14834570b
[2]: jiixyj/epoll-shim#15

Build tested on:
    11.3 aarch64
    11.3 amd64
    11.3 armv6
    11.3 i386
    12.0 amd64
    12.0 i386
    12.1 aarch64
    12.1 amd64
    12.1 armv6
    12.1 armv7
    12.1 i386
    13.0 amd64
    13.0 i386
    Base GCC 4.2.1 (mimics powerpc*, mips*, riscv64)

Run tested with:
    multimedia/libva-intel-driver
    multimedia/mpv
    www/firefox + MOZ_ENABLE_WAYLAND
    x11-servers/xwayland-devel
    x11-wm/cage
    x11-wm/sway
    x11/wl-clipboard

PR:  244059
Submitted by: jbeich
Tested by: manu
Reviewed by: manu
Approved by: x11 (bapt)
Differential Revision: https://reviews.freebsd.org/D23643
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

Successfully merging a pull request may close this issue.

5 participants