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

Multimonitor startup delay on X11 #5802

Closed
axgkl opened this issue Jul 11, 2024 · 3 comments
Closed

Multimonitor startup delay on X11 #5802

axgkl opened this issue Jul 11, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@axgkl
Copy link

axgkl commented Jul 11, 2024

What Operating System(s) are you seeing this problem on?

Linux X11

Which Wayland compositor or X11 Window manager(s) are you using?

dwm

WezTerm version

wezterm 20240701-070926-69686f45 (also wezterm 20240203-110809-5046fc22)

Did you try the latest nightly build to see if the issue is better (or worse!) than your current version?

Yes, and I updated the version box above to show the version of the nightly that I tried

Describe the bug

Just additional infos to the startup delay, maybe useful for you (?)
Please close this if its not a bug / not helpful.

Problem

  • Fast start on single laptop monitor.
  • Significant delay (~half a second), when hdmi monitor is attached (even when started on the same laptop monitor)

See also: #2339 and #2073. My xrandr is fast.

Test Setup

Ran these, with hdmi cable plugged in (slow) and pulled out (fast):

WEZTERM_LOG=trace /usr/bin/wezterm --config-file ./exitconf.lua 2>&1 | tee wez_perf

with

$ cat exitconf.lua
return { default_prog = { "/usr/bin/sleep", "0" },}

Then I normalized the timestamps, to show the offset from 0, not the absolute time.

Findings
  1. Nearly half a second difference:
$ tail -n 1 wez_perf_hdmi
0.528  TRACE  wezterm_gui::frontend              > Mux is now empty, terminate gui
$ tail -n 1 wez_perf_no_hdmi
0.121  TRACE  wezterm_gui::frontend              > Mux is now empty, terminate gui
  1. No sign. deviation between app image and fedora rpm

  2. No sign. deviation between stable and nightly

  3. Looking into the perf files, I noticed these:

2024-07-11_2842x295_scrot

Discussion

  1. At start both report loading the config
  2. Both run equally fast until (including) RequestedWindowGeometry.
  3. The fast single monitor version continues immediately with window::connection Screens { main: ScreenInfo .... (note: I just pulled the hdmi cable, w/o reconfiguring the monitors, which explains why HDMI is still reported by ScreenInfo)
  4. The slow hdmi version continues with two times loading again the config. E.g. 0.206 🟥DEBUG config > paths "." changed, reload config, ...) (note: I marked that with 🟥 in the screenshot) - and looses 0.4 seconds until Screens is showing up.

I don't know, if ScreenInfo would come faster, if you could prevent that 2x reloading of the config - or if it does anyway not matter and X11 is just that slow delivering the info. If so, maybe you could allow to specify it, for wezterm, in the config file? Just an idea which I would gladly accept if startup would be as fast as single monitor, then 😊

The 2 Testfiles are attached.

Thanks for wezterm!

wezperf.zip

To Reproduce

See above test setup

Configuration

See above - test setup.

Expected Behavior

Avoid loading the config 2 times, maybe that makes multimonitor X11 starts 0.4 secs faster (?)

Logs

See above the zip of the trace perf

Anything else?

No response

@axgkl axgkl added the bug Something isn't working label Jul 11, 2024
@wez
Copy link
Owner

wez commented Jul 13, 2024

Try putting your test configuration file in a directory that isn't modified during startup. That will eliminate the extraneous configuration reloads.

In general: there isn't much we can do about X11/XRandR being slow at returning information on startup, so I'm not sure that there is really anything to fix here.

@wez wez added the waiting-on-op Waiting for more information from the original poster label Jul 13, 2024
@axgkl
Copy link
Author

axgkl commented Jul 14, 2024

@wez

Try putting your test configuration file in a directory that isn't modified during startup. That will eliminate the extraneous configuration reloads.

🤦‍♂️ I'm sorry, did not consider that. In deed, the reloads are gone now.

So it's really X11, which costs us 0.4 secs at startup just to deliver that ScreenInfo.

0.05  TRACE  wezterm_gui::termwindow            > RequestedWindowGeometry { width: Pixels(820.0), height: Pixels(583.0), x: None, y: None, origin: ScreenCoordinateSystem }
0.42  TRACE  window::connection                 > Screens { main: ScreenInfo { name: "HDMI-1", rect: Rect(3840x2160 at (0, 0)), scale: 1.0, max_fps: Some(30), effective_dpi: Some(96.0) }...

And I guess that info can't be hardcoded in the config file.

So yeah, thanks Wez!

Finally the first reason to consider wayland ✨

@axgkl axgkl closed this as completed Jul 14, 2024
@github-actions github-actions bot removed the waiting-on-op Waiting for more information from the original poster label Jul 14, 2024
blukai added a commit to blukai/wezterm that referenced this issue Aug 10, 2024
related issue: wez#5802

requesting `GetScreenResourcesCurrent` instead of `GetScreenResources`
brings startup times down from 1.5 seconds to 30 microseconds on my
machine (measured with dumb printlns).

according to some findings `GetScreenResourcesCurrent` may return
nothing, so i kept `GetScreenResources` there as a fallback, just in
case, although I'm not 100% sure that it's necessary. see:
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbscreen.cpp#L963
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbconnection_screens.cpp#L390

also worth to note that i3 does not rely on
`xcb_randr_get_screen_resources`, but only on
`xcb_randr_get_screen_resources_current`, see:
- https://github.com/search?q=repo%3Ai3%2Fi3%20get_screen_resources&type=code
blukai added a commit to blukai/wezterm that referenced this issue Aug 10, 2024
related issue: wez#5802

requesting `GetScreenResourcesCurrent` instead of `GetScreenResources`
brings startup times down from 1.5 seconds to 30 microseconds on my
machine (measured with dumb printlns).

according to some findings `GetScreenResourcesCurrent` may return
nothing, so i kept `GetScreenResources` there as a fallback, just in
case, although I'm not 100% sure that it's necessary. see:
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbscreen.cpp#L963
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbconnection_screens.cpp#L390

also worth to note that i3 does not rely on
`xcb_randr_get_screen_resources`, but only on
`xcb_randr_get_screen_resources_current`, see:
- https://github.com/search?q=repo%3Ai3%2Fi3%20get_screen_resources&type=code
wez pushed a commit that referenced this issue Aug 11, 2024
related issue: #5802

requesting `GetScreenResourcesCurrent` instead of `GetScreenResources`
brings startup times down from 1.5 seconds to 30 microseconds on my
machine (measured with dumb printlns).

according to some findings `GetScreenResourcesCurrent` may return
nothing, so i kept `GetScreenResources` there as a fallback, just in
case, although I'm not 100% sure that it's necessary. see:
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbscreen.cpp#L963
- https://github.com/qt/qtbase/blob/c234700c836777d08db6229fdc997cc7c99e45fb/src/plugins/platforms/xcb/qxcbconnection_screens.cpp#L390

also worth to note that i3 does not rely on
`xcb_randr_get_screen_resources`, but only on
`xcb_randr_get_screen_resources_current`, see:
- https://github.com/search?q=repo%3Ai3%2Fi3%20get_screen_resources&type=code
wez added a commit that referenced this issue Aug 11, 2024
Copy link
Contributor

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 14, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants