I'm continuing down a rabbit hole that started in alacritty/alacritty#1603 and continued in rust-windowing/glutin#1070. Specifically, it looks like my terminal (alacritty), which uses glutin, which uses init, is much slower to spawn its initial window in certain cases. In particular, on my laptop (a 6th generation Lenovo X1 Carbon, so new hardware), there is a marked difference in the time it takes to spawn a single winit window depending on whether an external monitor is connected or not.
In particular, running the following code with --release:
extern crate winit;
fn main() {
let mut events_loop = winit::EventsLoop::new();
let _window = winit::WindowBuilder::new()
.with_title("A fantastic window!")
.build(&events_loop)
.unwrap();
events_loop.run_forever(|_| winit::ControlFlow::Break);
}
Without an external monitor connected:
0.01user 0.00system 0:00.14elapsed 14%CPU (0avgtext+0avgdata 6312maxresident)k
0inputs+0outputs (0major+544minor)pagefaults 0swaps
With an external monitor connected:
0.01user 0.00system 0:00.48elapsed 4%CPU (0avgtext+0avgdata 6340maxresident)k
0inputs+0outputs (0major+533minor)pagefaults 0swaps
That's 0.14s to 0.48s on the same system with a different monitor configuration, which seems surprising.
I took some perf profiles, though there's relatively little fidelity since I just spawn and immediately close a window. Without external monitor:

With external monitor:

The relevant lines from xrandr -q in the two configurations are:
Screen 0: minimum 320 x 200, current 2560 x 1440, maximum 8192 x 8192
eDP-1 connected 2560x1440+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
2560x1440 60.01*+ 59.99 59.99 59.96 59.95
and
Screen 0: minimum 320 x 200, current 3120 x 1920, maximum 8192 x 8192
eDP-1 connected 1920x1080+0+0 (normal left inverted right x axis y axis) 309mm x 174mm
1920x1080 60.01 59.97 59.96* 59.93
HDMI-1 connected primary 1200x1920+1920+0 left (normal left inverted right x axis y axis) 546mm x 352mm
1920x1200 59.95*+
1920x1080 60.00 50.00 59.94 59.99
I'm continuing down a rabbit hole that started in alacritty/alacritty#1603 and continued in rust-windowing/glutin#1070. Specifically, it looks like my terminal (
alacritty), which usesglutin, which usesinit, is much slower to spawn its initial window in certain cases. In particular, on my laptop (a 6th generation Lenovo X1 Carbon, so new hardware), there is a marked difference in the time it takes to spawn a singlewinitwindow depending on whether an external monitor is connected or not.In particular, running the following code with
--release:Without an external monitor connected:
With an external monitor connected:
That's 0.14s to 0.48s on the same system with a different monitor configuration, which seems surprising.
I took some perf profiles, though there's relatively little fidelity since I just spawn and immediately close a window. Without external monitor:


With external monitor:
The relevant lines from
xrandr -qin the two configurations are:and