16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-19 04:19:19 +02:00

Skip pure-visual leaf includes in the infrastructure pass

On a million-instance scenery (tomaszewo) the infra pass was spending ~24s
reopening pure-visual leaf twins (grass.incb etc.) just to skip their content --
~200k cParser constructions, because every flora include reopens the same leaf.

Twin header now flags whether a file has any infrastructure node or include
(format bumped to v10). A pure-visual leaf (flora .incb: triangles + transform
directives only) has it clear, so the infra pass skips opening it: the first open
of each file caches the verdict, later opens are dropped before construction.

Result on tomaszewo: infra 55s -> 31s, getToken 1.06M -> 89k. Also adds a load
profiler (per-type build time, dispatch time, getToken count) behind WriteLog so
the next bottleneck is measured, not guessed (it's now the 25s of decorative
vehicle media loading).
This commit is contained in:
maj00r
2026-06-25 00:53:24 +02:00
parent 4a9bfdc0aa
commit ef4e99a582
6 changed files with 114 additions and 4 deletions

View File

@@ -2017,8 +2017,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
*/
// utworzenie parametrów fizyki
MoverParameters = new TMoverParameters(iDirection ? fVel : -fVel, Type_Name, asName, Cab);
// --- profile vehicle load (LoadFIZ physics parse vs LoadMMediaFile model/textures) ---
static double s_fiztime = 0.0, s_mediatime = 0.0; static long s_vehcount = 0;
auto const s_t0 = std::chrono::steady_clock::now();
// McZapkie: TypeName musi byc nazwą CHK/MMD pojazdu
if (!MoverParameters->LoadFIZ(asBaseDir))
bool const s_fizok = MoverParameters->LoadFIZ(asBaseDir);
s_fiztime += std::chrono::duration<double>( std::chrono::steady_clock::now() - s_t0 ).count();
if (!s_fizok)
{ // jak wczytanie CHK się nie uda, to błąd
if (ConversionError == 666)
ErrorLog( "Bad vehicle: failed to locate definition file \"" + BaseDir + "/" + Type_Name + ".fiz" + "\"" );
@@ -2347,7 +2352,13 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
*/
// wczytywanie z pliku nazwatypu.mmd, w tym model
erase_extension( asReplacableSkin );
auto const s_t1 = std::chrono::steady_clock::now();
LoadMMediaFile(Type_Name, asReplacableSkin);
s_mediatime += std::chrono::duration<double>( std::chrono::steady_clock::now() - s_t1 ).count();
if( ( ++s_vehcount % 500 ) == 0 ) {
WriteLog( "VEH PROFILE @" + std::to_string( s_vehcount ) + ": LoadFIZ " + std::to_string( s_fiztime )
+ "s, LoadMMediaFile " + std::to_string( s_mediatime ) + "s" );
}
// McZapkie-100402: wyszukiwanie submodeli sprzegów
btCoupler1.Init( "coupler1", mdModel ); // false - ma być wyłączony
btCoupler2.Init( "coupler2", mdModel );