mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-20 06:49: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:
@@ -57,6 +57,12 @@ class cParser //: public std::stringstream
|
||||
// true when this (top-level) file is served from a binary twin, i.e. a second
|
||||
// (visual) pass via restartReplay() is possible. false for a text/compile load.
|
||||
bool isReplaying() const { return m_replay; }
|
||||
// true if this twin has any infrastructure node or include (so the infra pass must process
|
||||
// it); false for a pure-visual leaf (a flora .incb), which the infra pass can skip opening.
|
||||
bool infraRelevant() const;
|
||||
// clears the per-load cache of which include files are pure-visual leaves (call at the start
|
||||
// of a scenario load so a rebake that changed a file's class isn't masked by a stale entry).
|
||||
static void clearInfraSkipCache();
|
||||
// skips the rest of the node currently being replayed in O(1) (jump over its v6 marker
|
||||
// span), delegating to the active include child that is actually serving it. returns
|
||||
// false if the skip can't be done here (e.g. a text include with no binary twin), so the
|
||||
@@ -212,6 +218,8 @@ class cParser //: public std::stringstream
|
||||
// --- binary scenery twin support ---
|
||||
// last token produced by readTokenFromStream was (partly) quoted -> case preserved
|
||||
bool m_lastquoted { false };
|
||||
// per-load cache: include path -> true if it's a pure-visual leaf the infra pass skips opening
|
||||
static std::map<std::string, bool> s_infraskip;
|
||||
// replay: this file is served from its binary twin instead of text
|
||||
bool m_replay { false };
|
||||
bool m_replayexhausted { false }; // all twin entries consumed (for inline eof())
|
||||
|
||||
Reference in New Issue
Block a user