18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-03 11:15:23 +01:00
Commit Graph

2 Commits

Author SHA1 Message Date
maj00r cbbb0b23fb fix(world): the tape of the logic cache is bytes from the start, read an entry at a time
The parser tape kept a structure of about 70 bytes per token, so a scenery of 12 million tokens (Glinojeck)
took 1.8 GB at its peak while recorded and 1.5 GB while replayed, against 0.5 GB read from its files. The tape
is now written as it's recorded (parser_tape::writer, about 10 bytes a token) and decoded as it's replayed
(parser_tape::reader, tokens as views of the bytes); the names of the files are entries of the tape, and an
end mark tells a tape cut short. Glinojeck now peaks at 712 MB recorded and 601 MB replayed.

Checked in the game, on a test folder made of junctions to the data with a scenery folder of its own (nothing
was written into the SVN working copy): td.scn (23 481 entries, 29 files, a cache of 28 KB) and Glinojeck.scn
(11.9 million entries, 63 files, a cache of 8.5 MB), each run in --test for 120 s of simulation with seed 1
from the files with world.binary 0, then recorded and replayed with world.binary 1: the physics logs of every
train are the same bit for bit in all runs, and so are the error logs.
2026-12-02 23:03:28 +01:00
maj00r cfbe515db8 feat(parser): a tape of what the scenery parser gave its reader, and a parser replaying it
Step 2c of docs/world-format-eu07.md (#516, section 7): the logic layer of the cache holds the node definitions as
tokens read back through today's parsers. cParser::startRecording() makes the outermost parser write down every
token as it comes out to the reader (includes expanded, template parameters put in, injected text included),
with what the reader may ask about it (Name, Line, LineMain, TokenBegin/End, InLayerFile), and the side effects
the includes have on the way: the node groups of *.inc templates opened and closed, and the terrain files the
binary terrain stands in for. A parser made from the tape gives the same reader the same answers and repeats
the side effects at the same places, with no file opened: injectString() does nothing there, as the tape holds
the injected tokens already. The reads the parser makes for itself (the name and parameters of an include) are
not recorded.

With a tape the fast path that takes model entries straight from the text is off (remainingText() is empty),
so every token goes through the tape. The loader takes the case-kept header of a node from the new
headerText(4), its first four words: the same words as before, recorded and replayed as a text entry. Without
a tape nothing changes.

parser_tape::write/read keep a tape as bytes, the state of a token as differences from the one before in
variable-length integers.

Tests: a reader asking the way the loader does (several tokens, case-kept ones, a vector, a look ahead, the
header) gets the same transcript from the files with and without recording and from the tape through bytes,
with templates, parameters, nested includes, injected text and traction loaded or left out; the node groups
are on the tape, a skipped terrain file is counted on replay as on the first reading, and a cut or foreign
tape doesn't read.
2026-12-02 22:02:58 +01:00