From 9f7217256b2d70e3ab9aa10ea899b729ee702418 Mon Sep 17 00:00:00 2001 From: Hirek193 Date: Fri, 23 Oct 2026 20:12:02 +0200 Subject: [PATCH] fix(physics): the external program messages (multiplayer) no longer keep the physics steps in one thread, only network sessions do; the debug panel tells what keeps them in one --- rendering/opengl46/opengl46renderer.cpp | 2 +- utilities/Timer.h | 2 ++ vehicle/DynObj.cpp | 13 ++++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/rendering/opengl46/opengl46renderer.cpp b/rendering/opengl46/opengl46renderer.cpp index e5e17b7a..cceed1a4 100644 --- a/rendering/opengl46/opengl46renderer.cpp +++ b/rendering/opengl46/opengl46renderer.cpp @@ -866,7 +866,7 @@ void opengl46_renderer::SwapBuffers() ( counts.threads > 1 ? "steps on " + std::to_string( counts.threads ) + " threads: " + std::to_string( counts.groups ) + " groups, largest " + std::to_string( counts.largestgroup ) + ", " + std::to_string( counts.maingroups ) + " in the main thread (forces by kind not timed)" : - std::string{ "steps on 1 thread" } ), + "steps on 1 thread (pool of " + std::to_string( counts.pool ) + ( counts.singlethread.empty() ? std::string{ ")" } : ", off by " + counts.singlethread + ")" ) ), "" ); char const *const kindnames[] = { "rail, within ", "rail, farther", "road, within ", "road, farther" }; text += timeline( 3, "by kind (near: " + nearlimit + ")", " count stand forces update" ); diff --git a/utilities/Timer.h b/utilities/Timer.h index 8a703d97..189a97be 100644 --- a/utilities/Timer.h +++ b/utilities/Timer.h @@ -204,6 +204,8 @@ struct subsystem_stopwatches { // the steps of the physics: threads, the groups of vehicles they were split in, the largest one, the groups done in the main // thread (vehicle_table::update_steps_parallel()) unsigned int threads { 1 }; + unsigned int pool { 1 }; // threads of worker_pool + std::string singlethread; // what keeps the steps in one thread, if anything unsigned int groups { 0 }; unsigned int largestgroup { 0 }; unsigned int maingroups { 0 }; diff --git a/vehicle/DynObj.cpp b/vehicle/DynObj.cpp index abbabb38..c8268db5 100644 --- a/vehicle/DynObj.cpp +++ b/vehicle/DynObj.cpp @@ -8681,15 +8681,22 @@ vehicle_table::update( double Deltatime, int Iterationcount ) { Timer::subsystem.vehicles_prepare.stop(); Timer::subsystem.vehicles_forces.start(); auto const totaltime { Deltatime * Iterationcount }; // caƂkowity czas - // the steps of the physics on many threads (Global.performance_cpucores). not in a network session, which keeps the draws of - // Random() in step across the machines: the threads have engines of their own + // the steps of the physics on many threads (Global.performance_cpucores). not in a network session (network.server, .client), + // which keeps the draws of Random() in step across the machines: the threads have engines of their own. the messages to + // external programs (Global.iMultiplayer) don't mind auto &workers { Workers() }; auto const parallel { ( workers.size() > 1 ) - && ( Global.iMultiplayer == 0 ) && Global.network_servers.empty() && ( false == Global.network_client.has_value() ) }; counts.threads = ( parallel ? static_cast( workers.size() ) : 1u ); + // why not, for the debug panel + counts.pool = static_cast( workers.size() ); + counts.singlethread = + ( workers.size() <= 1 ? "performance.cpucores " + std::to_string( Global.performance_cpucores ) : + false == Global.network_servers.empty() ? std::string{ "network.server" } : + Global.network_client.has_value() ? std::string{ "network.client" } : + std::string{} ); if( parallel ) { update_steps_parallel( Deltatime, Iterationcount, coarse ); }