Where Thrawn's Revenge's galactic lag comes from, and a data-only fix that more than doubled the frame rate in my tests

I spent a few weeks measuring TR's galactic map frame by frame. This post explains what makes it slow, what I changed (XML and Lua only, as a submod for TR), and how I tested it. I saw no large change in which factions own which planets, though that check is coarse.

34 → 81 fps
plain TR to the Full fix: average galactic frame rate at 1920×1080 (29.4 ms → 12.4 ms a frame)
1.8 s → 0.3 s
plain TR to the Full fix: longest frame in each 120-galaxy-second test, on average
30 games
fresh games, 10 per version; I wrote the plan before the first one and excluded none
Average frame time in each of the 30 test games
010203040ms per frame (lower is better)Plain TRPlain TR, run: 24.3 ms per frame (lower is better)Plain TR, run: 27.0 ms per frame (lower is better)Plain TR, run: 28.1 ms per frame (lower is better)Plain TR, run: 28.8 ms per frame (lower is better)Plain TR, run: 29.0 ms per frame (lower is better)Plain TR, run: 29.8 ms per frame (lower is better)Plain TR, run: 30.1 ms per frame (lower is better)Plain TR, run: 30.4 ms per frame (lower is better)Plain TR, run: 31.6 ms per frame (lower is better)Plain TR, run: 35.1 ms per frame (lower is better)29.4 ms ≈34 fpsCore fixesCore fixes, run: 16.2 ms per frame (lower is better)Core fixes, run: 16.8 ms per frame (lower is better)Core fixes, run: 17.2 ms per frame (lower is better)Core fixes, run: 17.5 ms per frame (lower is better)Core fixes, run: 18.0 ms per frame (lower is better)Core fixes, run: 18.2 ms per frame (lower is better)Core fixes, run: 19.1 ms per frame (lower is better)Core fixes, run: 19.5 ms per frame (lower is better)Core fixes, run: 20.0 ms per frame (lower is better)Core fixes, run: 20.2 ms per frame (lower is better)18.3 ms ≈55 fpsFull fixFull fix, run: 10.8 ms per frame (lower is better)Full fix, run: 11.4 ms per frame (lower is better)Full fix, run: 12.2 ms per frame (lower is better)Full fix, run: 12.2 ms per frame (lower is better)Full fix, run: 12.3 ms per frame (lower is better)Full fix, run: 12.3 ms per frame (lower is better)Full fix, run: 12.7 ms per frame (lower is better)Full fix, run: 13.2 ms per frame (lower is better)Full fix, run: 13.3 ms per frame (lower is better)Full fix, run: 13.6 ms per frame (lower is better)12.4 ms ≈81 fps
Each dot is one fresh game, measured over 120 seconds of galaxy time. The black tick is the average of the ten games; the shaded band is the 95% range for the true average (built so that, across repeated studies, it would catch the true value 95 times in 100). The three groups don't come close to overlapping. Core fixes and Full fix are explained below.

The short version. TR's galaxy is slow for two separate reasons.

1. A freeze every 40 seconds of galaxy time. Every AI faction moves its idle units on the same frame, and each move starts a slow target search. Spreading those passes out across the 40 seconds, and letting units that ask the same question share an answer, removed the multi-second freeze in my early-campaign tests. I haven't measured the final version late in a long campaign, where frames over a second are still likely, and the answer sharing occasionally sends a unit after a different target than TR would (about 1 time in 270 in my checks), explained below.

2. A slow frame even when nothing is happening. In my early tests TR's typical frame cost about 28 ms against vanilla's 4. About half of that is the AI scoring its goals and the engine rebuilding galaxy-wide paths. Rewriting TR's AI equations so they do the same math with fewer lookups, and giving the AI a short breather between goal sweeps, cuts it substantially. The Workshop version leaves the breather out so the AI scores its goals as often as in TR (see "What I changed").

If you only want the changes, skip to "What I changed". The sections before it show where the time goes.

What it looks like when you play

Averages hide the hitches you feel, so I counted how often frames ran long per minute of real time.

How often the game hitches, by size of hitch
Plain TRCore fixesFull fixPlain TR: 321.5 frames over 50 ms per minute322Core fixes: 224.0 frames over 50 ms per minute224Full fix: 127.1 frames over 50 ms per minute127over 50 msper minute of playPlain TR: 37.4 frames over 100 ms per minute37Core fixes: 38.1 frames over 100 ms per minute38Full fix: 18.7 frames over 100 ms per minute19over 100 msper minute of playPlain TR: 3.5 frames over 250 ms per minute3.5Core fixes: 3.0 frames over 250 ms per minute3.0Full fix: 0.5 frames over 250 ms per minute0.5over 250 msper minute of playPlain TR: 1.3 frames over 1 second per minute1.3Core fixes: 0.0 frames over 1 second per minute0.0Full fix: 0.0 frames over 1 second per minute0.0over 1 secondper minute of play
Each bar is the average over that version's 10 games, per minute of real time after cutting out time on battle prompts and result screens. Each panel has its own scale. The sizes overlap: a frame over 1 second also counts as over 250, 100 and 50 ms.

Plain TR averages about one frame over a full second per minute of play. Neither fixed version had a single one in 20 games, and every frame of every game was logged.

The Core fixes alone don't cut the number of 100 ms hitches per minute. They make each frame cheaper, so more frames fit in a minute, but the 100 ms ones stay. The two extra changes in the Full fix halve them.

The single longest logged frame in each game
05001000150020002500longest logged frame in the game, msPlain TRPlain TR, run: 1297.5 longest logged frame in the game, msPlain TR, run: 1715.9 longest logged frame in the game, msPlain TR, run: 1722.5 longest logged frame in the game, msPlain TR, run: 1727.2 longest logged frame in the game, msPlain TR, run: 1741.9 longest logged frame in the game, msPlain TR, run: 1814.3 longest logged frame in the game, msPlain TR, run: 1873.0 longest logged frame in the game, msPlain TR, run: 1873.9 longest logged frame in the game, msPlain TR, run: 2035.3 longest logged frame in the game, msPlain TR, run: 2340.4 longest logged frame in the game, ms1.81 s averageCore fixesCore fixes, run: 326.3 longest logged frame in the game, msCore fixes, run: 347.8 longest logged frame in the game, msCore fixes, run: 365.3 longest logged frame in the game, msCore fixes, run: 368.4 longest logged frame in the game, msCore fixes, run: 370.0 longest logged frame in the game, msCore fixes, run: 374.4 longest logged frame in the game, msCore fixes, run: 404.3 longest logged frame in the game, msCore fixes, run: 435.8 longest logged frame in the game, msCore fixes, run: 536.6 longest logged frame in the game, msCore fixes, run: 555.1 longest logged frame in the game, ms0.41 s averageFull fixFull fix, run: 239.3 longest logged frame in the game, msFull fix, run: 243.3 longest logged frame in the game, msFull fix, run: 247.1 longest logged frame in the game, msFull fix, run: 247.4 longest logged frame in the game, msFull fix, run: 258.5 longest logged frame in the game, msFull fix, run: 266.9 longest logged frame in the game, msFull fix, run: 274.6 longest logged frame in the game, msFull fix, run: 292.5 longest logged frame in the game, msFull fix, run: 293.6 longest logged frame in the game, msFull fix, run: 303.1 longest logged frame in the game, ms0.27 s average
One dot per game. In plain TR, every game had a freeze of 1.3 to 2.3 seconds. With the Core fixes the worst frame in any game was 0.56 seconds, and with the Full fix 0.30 seconds.

With plain TR, the galaxy clock advanced 0.69 seconds per real second at speed 1 because the game couldn't keep up; with the Full fix it advanced 0.82. While the galaxy is running (not paused on a battle prompt), the same real time gets you about 20% more campaign.

Problem 1: the 40-second freeze

If you've played TR's galactic conquest for a while you know this one: the galaxy stops dead for a second or more, roughly every 40 seconds, and it's worse in a campaign that has been running a while.

Frame times over 160 seconds, 50 AI cycles into a campaign
Plain TR: all twelve AI players run their idle-unit pass on the same frame0 s1 s2 s3 s3.48 s frame3.22 s frameSame campaign age, passes spread out (the stagger change)0 s1 s2 s3 s1.26 s frame1.15 s frame0s40s80s120s160sreal seconds into the window
Each line shows the slowest frame in every quarter second. A 40-second galaxy cycle takes about a minute of real time here, because the game can't keep up. Top: plain TR, with a 3 to 3.5 second freeze every cycle, followed straight away by a second frame of about one second. Bottom: the same campaign age with each faction's pass moved to its own moment; the biggest frame is about 1.3 seconds and it's one faction's pass, not twelve. (This was an earlier test version of the stagger; the final one spreads factions more evenly.)

What causes it

The freeze is GalacticFreeStore.lua. Every AI faction has a "free store": the units that aren't assigned to an attack or a defense. TR sets the free store's unit service rate to 40 seconds, so every 40 seconds the engine calls On_Unit_Service for every idle unit of that faction. Many of those calls end in MoveUnit, which runs a target search (FindTarget) to decide where the unit should go.

Two things make this hurt:

How the freeze grows over one long campaign
Freeze length, seconds0246cycle 4: 2.47–3.274cycle 10: 2.92–2.9310cycle 25: 3.17–3.7525cycle 50: 4.17–4.7650cycle 75: 3.78–5.2175cycle 100: 2.72–4.08100AI cycleIdle AI units waiting05001,000cycle 4: 514–5454cycle 10: 602–62710cycle 25: 699–70825cycle 50: 960–97450cycle 75: 799–86975cycle 100: 720–791100AI cyclems per target search01020cycle 4: 8.64cycle 10: 9.210cycle 25: 10.525cycle 50: 10.750cycle 75: 12.975cycle 100: 15.9100AI cycle
One campaign run from start to cycle 100 (a cycle is 40 galaxy seconds). Each checkpoint measured two or three cycles; the line shows their lowest to highest value and the dot sits at the middle of that range. Left: total freeze per cycle. Middle: idle units sitting in all the free stores. Right: average cost of one target search. The freeze is largest around cycles 50 to 75, when the free stores are fullest, then shrinks somewhat as battles thin out the armies, even though each search keeps getting slower. So it isn't a simple function of campaign age: it depends on how many units the AI leaves idle and how much territory it holds.

TR's 10% move allowance doesn't limit the searches. The allowance only counts searches that end in a move, and 67 to 89% of searches end without one (no target found, or TR's own checks reject it). So the number of searches tracks the number of idle units, not the allowance.

The freeze also survives saving and reloading. The free-store state comes back from the save, timer included.

Problem 2: the slow frame when nothing is happening

Even between freezes, TR's galaxy runs about 28 to 31 ms a frame. I ran the same measurement on vanilla FoC's largest galaxy for comparison.

Typical frame on the galactic map, TR against vanilla
0 ms10 ms20 ms30 ms0255075100campaign age, in 40-second AI cyclesThrawn's Revenge, cycle 1: 28.6 ms typical frameThrawn's Revenge, cycle 25: 28.1 ms typical frameThrawn's Revenge, cycle 50: 28.2 ms typical frameThrawn's Revenge, cycle 75: 31.2 ms typical frameThrawn's Revenge, cycle 100: 30.1 ms typical frameThrawn's Revenge28.1–31.2 msVanilla FoC, cycle 1: 3.6 ms typical frameVanilla FoC, cycle 25: 3.6 ms typical frameVanilla FoC, cycle 50: 3.9 ms typical frameVanilla FoC, cycle 75: 4.3 ms typical frameVanilla FoC, cycle 100: 5.3 ms typical frameVanilla FoC3.6–5.3 ms
Median frame time (the middle value once frames are sorted from fastest to slowest) at five points in a 100-cycle campaign, same machine and settings. TR's galaxy is much bigger (more planets, more factions), so this isn't a fair fight, but it shows how much room there is. Drawing costs roughly the same in both. The whole difference is game logic.

To find where that logic time goes, I sampled what the game was doing about 170 times a second and grouped the samples by engine system.

Where a typical frame goes
Scoring AI goalsPath rebuildsOther galaxy upkeepOther AIDrawing the frameLua scriptsUnassigned0 ms10 ms20 ms30 msestimated ms per typical frame, early campaignThrawn's RevengeThrawn's Revenge, Scoring AI goals: about 10 msThrawn's Revenge, Path rebuilds: about 4.8 msThrawn's Revenge, Other galaxy upkeep: about 5.2 msThrawn's Revenge, Other AI: about 1.4 msThrawn's Revenge, Drawing the frame: about 3.9 msThrawn's Revenge, Lua scripts: about 0.7 msThrawn's Revenge, Unassigned: about 2.6 ms≈28.6 msVanilla FoCVanilla FoC, Scoring AI goals: about 0.05 msVanilla FoC, Path rebuilds: about 0.01 msVanilla FoC, Other galaxy upkeep: about 0.13 msVanilla FoC, Other AI: about 0.03 msVanilla FoC, Drawing the frame: about 2.5 msVanilla FoC, Unassigned: about 0.88 ms≈3.6 ms
Estimates from a sampling profiler, early in a campaign (cycle 6). TR's two big costs are the AI scoring its goals, and galaxy upkeep, a big part of which is rebuilding paths. Lua, all of TR's scripts together, is under 1 ms. Drawing the frame is under 4 ms. Vanilla spends almost nothing on either big cost.

Cost 1: the AI scoring its goals

The galactic AI works through a list of possible moves: each is a goal from TR's AI XML (say, conquer a planet) paired with a target (which planet). Every frame, each AI faction scores one such pair, and scoring it means evaluating the perception equations behind it: the XML formulas that rate a planet or a fleet for that goal. One complete trip through that list is a sweep. TR's AI has no pause between sweeps on Normal and Hard (Galactic_AI_Goal_Cycle_Sleep_Duration is 0), so this runs every frame for every AI faction, all game.

The engine evaluates every term of an equation every time. Nothing short-circuits: multiplying by a zero doesn't skip the other factor. So the only ways to make this cheaper are fewer lookups per equation, or fewer evaluations. Some of TR's equations repeat the same lookup many times over; for example Is_Owned_By_Enemy makes 360 lookups.

By goal type, Conquer_To_Reconnect alone accounts for about 15% of a typical frame's game work.

Cost 2: rebuilding galaxy-wide paths

This one is in the engine, not TR. When a fleet arrives at a planet, leaves, merges or jumps, the engine clears that planet's displayed owner (its icon). When the planet is next updated, the engine sees the icon doesn't match the owner and rebuilds every faction's travel costs and shortest paths across the whole galaxy, even though nobody's ownership changed. In TR I counted 153 rebuilds in 20 seconds, against 8 in vanilla. Each one costs an estimated 20 ms at TR's galaxy size.

To check that this really costs what the profile says, I switched the icon clearing off in memory in a running game, as a one-off test. No files were changed, and this is not something anyone should ship. The chart includes two measures of the slower frames: the 95th percentile frame time is the time that 95% of frames are faster than, and the 99th percentile uses 99%.

Same game, path rebuild switched on and off
Engine as shippedIcon clearing switched off (test only)0 ms40 ms80 ms120 msMean frameMean frame, as shipped: 35.2 ms35.2 msMean frame, switched off: 26.7 ms26.7 ms95th percentile95th percentile, as shipped: 78.6 ms78.6 ms95th percentile, switched off: 45.5 ms45.5 ms99th percentile99th percentile, as shipped: 127 ms127 ms99th percentile, switched off: 72 ms72 ms
One game measured in 60-second windows with rebuilds switched on or off; this chart compares the first four windows (why four is below). With the rebuilds gone, the average frame time drops by a quarter, and both slower-frame measures drop by over 40%.

This was an exploratory test, not a pre-planned one. I ran six windows (on, off, off, on, on, off) and compare the first four. The last "off" window looked like the galaxy was held on a screen for part of it (unusually many very fast frames, and only 39 galaxy seconds advanced in 60 real seconds), though I couldn't confirm that, and the third "on" window then has no matching "off" beside it. A data-only mod can't switch this off. It can only make fewer fleet moves.

The rebuilds probably explain the second one-second frame after each freeze, too. During its pass, the free store issues hundreds of move orders. In the game where I logged who made each icon clear, the biggest freeze held 347 clears made by the script, and the very next frame ran 37 rebuilds back to back. A second logged game showed the same shape (237 clears in its biggest script freeze, then 38 rebuilds), though there I didn't record who made each clear. (The logging itself pauses the game at each clear, so those freezes ran longer than normal.) Across ordinary profiled games, though, only 13 of 30 long script frames were followed by a rebuild frame, so it's a strong pattern rather than a rule.

What the game was doing in its long frames
Path rebuildLua scriptSomething else0306090frames over 100 ms in a two-minute window, by what the game was doingPlain TR, game 1Plain TR, game 1, Path rebuild: 58 frames58Plain TR, game 1, Lua script: 9 frames9Plain TR, game 1, Something else: 10 frames1077 totalPlain TR, game 2Plain TR, game 2, Path rebuild: 65 frames65Plain TR, game 2, Lua script: 11 frames11Plain TR, game 2, Something else: 9 frames985 totalFull fixFull fix, Path rebuild: 27 frames27Full fix, Lua script: 3 framesFull fix, Something else: 8 frames838 total
Every frame over 100 ms in two minutes of real time, labelled by what most of the profiler's samples caught. (Profiling slows the game a little, so these frames run longer than in the main test.) In plain TR the long Lua frames (the free-store freeze) are few but huge, 1.7 to 2.1 seconds at the top. Path rebuilds make most of the moderate hitches. With the Full fix the Lua freezes are nearly gone. What remains is mostly rebuilds, which data can't reach.

What I changed

Everything is plain XML and Lua in a submod that loads on top of TR. TR's own files are never edited. It's on the Steam Workshop as a submod of TR (TR Galactic Lag Fix); the tests loaded the same files from a folder with Modpath. The submod's files are built by a small script from TR's own files, after it checks each one against the exact TR version the changes were written for. For the Lua, it appends wrappers to a byte-for-byte copy of TR's script. For the XML, it rewrites only the specific equation bodies and values it targets and leaves every other byte alone.

That means the submod carries its own copies of the TR files it changes. If a TR update changes one of those files, the submod's older copy would still load over it until I rebuild the submod for the new version.

I tested two bundles. Core fixes are the first four changes. Full fix is those four plus the last two. (In the build script, change 4 is two components, factoring and common-factors, so the Core bundle lists five.)

The Workshop version is the Full fix without changes 3 and 6, the two that make the AI act less often. I took them out after testing so the AI behaves closer to plain TR: it starts each goal sweep straight after the last, as TR does, and moves safe heroes every pass. The numbers in this write-up are for the tested bundles, which include the pause. I didn't time the Workshop build. By my rough estimate (explained under change 3), it's something like 2 to 4 ms a frame slower without the pause, and I haven't estimated the hero change. In the build script both are off unless you ask for them (sleep and hero-cadence).

The Lua changes only take effect in a new campaign. EaW saves store the scripts' functions, so loading an old save made without the layer brings back TR's own Lua. The XML changes should still apply, since the game reads them at start-up (I haven't confirmed that for every file), but the stagger, search sharing and hero change do nothing until a new campaign. The reverse (a save made with the layer, loaded without it) would bring the layer's functions back and may depend on it. I haven't tested that.

1. Stagger the free-store passes Core

Each AI faction's first free-store pass is shifted to its own slot in the 40-second cycle, then TR's normal 40-second rhythm carries on from there. The slot comes from the player ID (times the golden ratio, so no two factions land together). Same work per faction, just not all on one frame.

2. Share search results within a pass Core

Within one free-store pass, units of the same type at the same planet looking for the same kind of target reuse the first unit's search result instead of running it again. All of TR's own per-unit checks still run on that result. If a search result depends on something about the individual unit beyond its type and location, sharing could pick a different target than TR would. The build script has a check mode that runs the real search alongside every shared result and counts any disagreements. I've now run it in game, with one addition: for some units it also runs TR's own search twice, to see whether that search ever disagrees with itself. Over five games of the same campaign, 9 of 2,422 shared results (about 0.4%, or 1 in 270) pointed at a different target than TR's own search, while TR's search never disagreed with itself (0 of 2,812 repeats). So the difference is real but small: now and then a unit is sent after a different target than it would be in TR. I haven't measured whether that changes how a campaign plays out.

3. Give the AI a 10-second breather between goal sweeps Core not in the Workshop version

Sets Galactic_AI_Goal_Cycle_Sleep_Duration from 0 to 10 seconds for Normal and Hard (the Default and Skynet profiles). Easy Default already pauses for 40; the other difficulty profiles are left as TR ships them. The busiest factions have several hundred (goal, target) pairs and score one per frame, so by my estimate a full sweep takes something like 15 to 20 seconds at TR's normal frame rate; the breather adds 10 seconds after each sweep. Sweep length depends on frame rate, and the fixes change frame rate, so I haven't measured the actual change in how quickly the AI reacts. This is a real behaviour change: the pause can delay how soon the AI notices new opportunities, although the faster frame rate shortens each sweep, so the net effect is unmeasured. I picked 10 to keep the pause small.

I didn't measure what the pause saves on its own. Scoring goals costs about 10 ms of a typical plain-TR frame (see "Where a typical frame goes"), and the pause idles it for roughly a third of each cycle, so by my rough estimate it's worth something like 2 to 4 ms a frame once the equations are tidied. The Workshop version leaves it out, so the AI goes straight into its next sweep, as in TR. With faster frames, each sweep also finishes sooner than in plain TR.

4. Tidy up the AI equations Core

Rewrites equations in TRBasicGalacticEquations.xml, TROffensiveGalacticEquations.xml and DefensiveGalacticEquations.xml so repeated lookups are factored out and evaluated once. Think a·X + a·Y + a·Z becoming a·(X + Y + Z), applied hundreds of times. Before writing anything, the script checks algebraically that each rewritten equation is exactly the original polynomial. That's exact on paper; the game's floating-point arithmetic can round the last digits differently when terms are regrouped, so results can differ by tiny amounts. A few examples:

equationlookups beforeafter
Is_Connected_To_Enemy_Human380112
Is_Owned_By_Enemy36074
Is_Connected_To_Enemy19753
Is_Owned_By_Active_Enemy14447

It also factors the two scores every free-store target search evaluates for every friendly planet, which makes each search cheaper.

5. Group type checks into one lookup Full fix

Runs like c·IsType(A) + c·IsType(B) become a single IsType lookup with several Parameter_Type bindings, the same form TR already uses in Is_Important_Planet. Applied to BasicGalacticEquations_Generated.xml and BasicGalacticEquations.xml. The check assumes that a lookup listing several types returns the sum of the separate lookups. Under that assumption, it proves the equations equal before writing them. TR's own use of this form suggests the assumption holds.

6. Move idle heroes every other pass Full fix not in the Workshop version

Combat heroes sitting in a safe spot get re-positioned on alternate free-store passes instead of every pass. Any hero in danger, and every non-hero unit, still goes through TR's normal service. This is also a behaviour trade: a safe hero can take an extra 40 seconds to be sent somewhere new. The Workshop version leaves this out, so safe heroes are moved every pass, as in TR.

I only tested the bundles, not each change on its own, so I can't tell you exactly how much each one is worth. In this study, the Core fixes take 11.1 ms off the average frame, and the two Full-fix changes take off another 5.9 ms on top of that.

Does it change how the AI plays?

The point was to make the AI cheaper to run, not to change its decisions. So for every game I recorded who owned which planets at the end, and how many battles the AI started against me.

Planets owned by each faction at the end of each game
Plain TRCore fixesFull fix0102030planets owned at the end of the window (dot = average, line = lowest to highest)Empire (me)Empire (me), Plain TR: average 28.0 (26–30)Empire (me), Core fixes: average 28.5 (27–30)Empire (me), Full fix: average 28.7 (27–30)RebelRebel, Plain TR: average 17.7 (15–19)Rebel, Core fixes: average 18.0 (14–21)Rebel, Full fix: average 18.5 (16–21)Zsinj EmpireZsinj Empire, Plain TR: average 16.4 (13–18)Zsinj Empire, Core fixes: average 16.1 (14–19)Zsinj Empire, Full fix: average 17.1 (14–21)Greater MaldroodGreater Maldrood, Plain TR: average 12.0 (9–14)Greater Maldrood, Core fixes: average 12.4 (11–14)Greater Maldrood, Full fix: average 12.1 (8–15)Independent ForcesIndependent Forces, Plain TR: average 11.7 (11–13)Independent Forces, Core fixes: average 11.0 (10–12)Independent Forces, Full fix: average 11.2 (10–13)PentastarPentastar, Plain TR: average 10.0 (9–11)Pentastar, Core fixes: average 9.8 (9–10)Pentastar, Full fix: average 9.6 (9–10)WarlordsWarlords, Plain TR: average 9.8 (9–10)Warlords, Core fixes: average 9.5 (9–10)Warlords, Full fix: average 9.6 (9–10)Empire of the HandEmpire of the Hand, Plain TR: average 9.2 (8–10)Empire of the Hand, Core fixes: average 9.6 (9–10)Empire of the Hand, Full fix: average 9.4 (9–10)Hutt CartelsHutt Cartels, Plain TR: average 8.7 (7–11)Hutt Cartels, Core fixes: average 8.6 (7–10)Hutt Cartels, Full fix: average 7.8 (6–10)ChissChiss, Plain TR: average 8.0 (8–8)Chiss, Core fixes: average 8.0 (8–8)Chiss, Full fix: average 8.0 (8–8)Eriadu AuthorityEriadu Authority, Plain TR: average 7.4 (6–10)Eriadu Authority, Core fixes: average 7.0 (5–9)Eriadu Authority, Full fix: average 7.0 (4–9)Ssiruuvi ImperiumSsiruuvi Imperium, Plain TR: average 6.6 (5–7)Ssiruuvi Imperium, Core fixes: average 7.0 (7–7)Ssiruuvi Imperium, Full fix: average 6.7 (6–7)Killik HivesKillik Hives, Plain TR: average 6.0 (6–6)Killik Hives, Core fixes: average 6.0 (6–6)Killik Hives, Full fix: average 6.0 (6–6)Corporate SectorCorporate Sector, Plain TR: average 5.9 (5–6)Corporate Sector, Core fixes: average 6.1 (5–8)Corporate Sector, Full fix: average 6.0 (5–7)Hapes ConsortiumHapes Consortium, Plain TR: average 5.1 (5–6)Hapes Consortium, Core fixes: average 5.0 (5–5)Hapes Consortium, Full fix: average 5.0 (5–5)CorelliaCorellia, Plain TR: average 4.0 (4–4)Corellia, Core fixes: average 4.0 (4–4)Corellia, Full fix: average 4.0 (4–4)NeutralNeutral, Plain TR: average 2.5 (2–3)Neutral, Core fixes: average 2.7 (2–3)Neutral, Full fix: average 2.4 (2–3)YevethaYevetha, Plain TR: average 2.0 (2–2)Yevetha, Core fixes: average 2.0 (2–2)Yevetha, Full fix: average 2.0 (2–2)MandaloriansMandalorians, Plain TR: average 1.0 (1–1)Mandalorians, Core fixes: average 0.7 (0–1)Mandalorians, Full fix: average 0.9 (0–1)
The dot is the average across that version's 10 games; the line runs from the lowest to the highest. Every faction's average is within one planet across the three versions, and the contested factions' ranges overlap heavily. The Hutts drift down slightly with the fixes (8.7 → 8.6 → 7.8) and the Rebels up (17.7 → 18.0 → 18.5).

Battles the AI started against me during each test's measurement window. Note the window covers a bit more galaxy time than the 120 measured seconds, because stretches around battle screens were cut from the frame data but not from this count: 121 to 149 galaxy seconds, averaging 134 (plain), 132 (Core) and 132 (Full). The counts: 3.6 per game in plain TR (0 to 8), 3.0 with the Core fixes (1 to 5), and 2.7 with the Full fix (0 to 6). The difference between plain and Full fix is −0.9 battles, with a 95% range of −2.8 to +1.0. That's no clear change either way. Ten games is too few to say more.

This is a coarse check, early in one campaign. It found no large shift in who owns what, but individual games vary a lot (Zsinj ended anywhere from 13 to 21 planets), so smaller differences could hide in that noise. It can't prove the AI plays identically, and two of the changes (the breather and the hero cadence) deliberately trade a bit of reaction time for speed. The Workshop version leaves both out.

How I tested it

I set the test rules before collecting any results.

comparisonchange in average frame time (ms)95% range for the change (ms)
Full fix vs plain TR−17.0 ms−19.1 to −15.0 ms
Core fixes vs plain TR−11.1 ms−13.3 to −9.0 ms
Full fix vs Core fixes−5.9 ms−7.0 to −4.8 ms
These were planned as supporting measures, not the main test, so their ranges aren't adjusted for making several comparisons. The 95th percentile frame is the one that 95% of frames are faster than; the 99th, 99%.
also measuredplain TRCoreFullFull minus plain: 95% range for the change
95th percentile frame73.4 ms55.4 ms42.3 ms−35.0 to −27.3 ms
99th percentile frame121.5 ms107.2 ms71.9 ms−57.7 to −41.4 ms
frames over 100 ms1.85%1.17%0.39%−1.8 to −1.1 percentage points
galaxy seconds per real second0.690.760.82+0.11 to +0.16

When it ran: overnight on an idle machine, as planned, over about 6 hours 16 minutes, with nothing changed from the plan. Other programs used 15 to 24% of the CPU during the games, varying run to run. That's recorded per game, and it came out even across versions: 16.2% on average in the plain TR games, 16.6% in Core, 16.1% in Full.

The test script waited for each game to save its whole frame log before closing it, so no frames were lost.

How frames were timed: with a small DLL that sits between the game and Direct3D and logs every frame, the same build and settings in every game. Claude Opus 5.5 wrote the DLL, with GPT-6 Astra reviewing it adversarially until it signed off. It's only a measuring tool: the fix doesn't use it, and you don't need it to play with the fix.

What the timer itself costs. Every version ran the same DLL with the same settings, and its own work is inside every frame time and frame rate in this post. I haven't measured whether that work costs more or less in one version than another. I couldn't time a game with no DLL at all, because the outside timer that would do it needs admin rights I didn't have on this machine. So I measured the cost in two parts, in a separate test with its own written plan: 26 Full-fix games at 1920×1080, half of them with the DLL's optional measurements (GPU timing, per-draw timing and a memory sampler) switched off.

That test ran on a busier machine than the main study (other programs used 24 to 38% of the CPU, against 15 to 24%), and its frames were slower overall, about 16 to 24 ms instead of about 12, so its range came out about three times wider than planned. Four of its 30 games failed during the fast-forward and were excluded as the plan said: three after their campaign start timed out, and one after a normal start, for a reason I didn't investigate. After the first three I added one check, written down before it took effect: after a late start, if the game didn't answer my test scripts, end the game at once instead of after 30 minutes. No later start timed out, so the check never triggered, and it didn't change what was measured.

The "why" parts of this post (the freeze cause, where frame time goes, the path rebuilds) come from a sampling profiler and a debugger, in separate exploratory runs at a different window size, some before the first run of the main test and some after it. Those exploratory runs helped me find the causes; they were separate from the planned comparison of the bundles.

What didn't work

Not everything I tried helped, and some of it made things worse:

The order cap: no clear speed-up, several times the attacks
Mean frame time, ms01020Full fixFull fix: 13.9Full fix: 14.1Full fix: 15.0Full fix: 17.3Full fix + capFull fix + cap: 12.3Full fix + cap: 14.0Full fix + cap: 14.5Battles the AI started against me0510Full fix: 1Full fix: 2Full fix: 2Full fix: 2Full fix + cap: 6Full fix + cap: 7Full fix + cap: 8One dot per game. 4 games without the cap, 3 with it (one capped game stalled before measuring).
Frame time barely moved (−1.5 ms, 95% range −4.1 to +1.2), but the AI attacked me 6 to 8 times per window instead of 1 to 2. The cap is off and not part of either bundle.

The capped windows also ran longer in galaxy time (147 seconds on average against 129), so per galaxy second that's about 3.5 times as many attacks. And I ended with about 2.5 fewer planets. Holding back routine moves seems to leave units near the front, where they get swept into attacks, but that's a guess.

A small exploratory test with no pre-set plan: 4 games without the cap and 3 with it, because one capped game stalled before its measurement started, for a reason I didn't record.

That last result is why I treat changes that move fewer units as possible behaviour trade-offs.

Limits

Files and test results

The fix is on the Steam Workshop as a submod of TR: TR Galactic Lag Fix. It's the Full fix without the pause and the hero change (changes 3 and 6), so the AI plans goals and moves heroes as often as in TR. That exact build wasn't timed.

The script that builds the submod, the test plans, every game's frame log (the timer-cost test's included), and the analysis scripts are here: github.com/molosat/EaWX-Optimizer. You don't need the script to use the submod. It's there so anyone can see exactly what changed and check the build against TR's own files.

The frame timer is released separately, here: github.com/molosat/alamo-profiler. It's a timer-only build, not the exact DLL the tests ran: the same timing code, with the command channel my test scripts used to drive the game taken out. You build it from source and put its d3d9.dll in the folder of the executable the game actually runs (for Steam FoC, the corruption folder; it needs the current 64-bit build). It writes a log of every frame, and a Python script summarises the log. The test scripts belong to a private tool I'm not releasing, so you can check the frame logs and the analysis, but you can't replay my runs click for click. Use the timer in single player only, never in multiplayer.

Each change is small, readable and independent, so they can be used separately. I'd be interested in results from other machines, especially late in a long campaign.