From cdaa40ac3b08ac35e5902ba8338239e1202e84e4 Mon Sep 17 00:00:00 2001 From: jerrrrycho Date: Wed, 2 Dec 2026 07:04:33 +0100 Subject: [PATCH] perf(application): the hidden window of the test mode polled a few times a second The main loop called glfwPollEvents() every frame. With no messages waiting, PeekMessage called over and over yields the thread (ZwYieldExecution in the profile), so in a short frame it was a large part of it: 8.7% of the main thread on linia_107_objazdy, 0.3% on Tomaszewo. The test mode's window is hidden and takes no input, so there its messages are looked at every 50 ms. Outside the test mode they are polled every frame, as before. --- application/application.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/application/application.cpp b/application/application.cpp index 22293bb3c..f2cb51931 100644 --- a/application/application.cpp +++ b/application/application.cpp @@ -685,6 +685,10 @@ int eu07_application::run() { auto frame{0}; frame_pacer framepacer; + // the window of the test mode is hidden and takes no input: its messages are looked at a few times a second. looked for + // every frame, PeekMessage gives up the rest of the time slice of the thread when there are none, which in a short frame + // came to a tenth of it + auto nextpoll{std::chrono::steady_clock::now()}; Timer::subsystem.mainloop_period.start(); // main application loop while (!glfwWindowShouldClose(m_windows.front()) && !m_modestack.empty()) @@ -695,7 +699,11 @@ int eu07_application::run() Timer::subsystem.mainloop_total.start(); GfxRenderer->Frame_Start(); Timer::subsystem.loop_input.start(); - glfwPollEvents(); + if (false == Global.test.enabled || std::chrono::steady_clock::now() >= nextpoll) + { + glfwPollEvents(); + nextpoll = std::chrono::steady_clock::now() + std::chrono::milliseconds{50}; + } if (m_headtrack) m_headtrack->update();