My build planner for Path of Exile 2 publishes a “best build” per class, computed by a CI workflow. The same input has to produce the same build, on every machine, on every run. Today CI told me that no unique item helps the Witch, while my own machine had found two items worth 43% more damage three times in a row.
The setup
The project, poe2-ai-build-planner, runs a real calculation engine and searches for the best build per class under a versioned set of rules. A workflow computes all eight classes and publishes the results, so the app can offer a precomputed build per class.
The newest stage in that pipeline tries unique items. It takes the winning build and searches for uniques that improve it. Locally, the Witch came out with two items and 43% more damage. I ran that three times, got the same result three times, checked that a fresh profile shows the published number, and merged.
Then the workflow ran on CI. Same winner, same rule version, and for the Witch: “no unique helps”.
The misleading clues
I stopped the publication first. A wrong published result is worse than a late one.
The first explanation that comes to mind is “CI is different”: another seed, another dependency, another build of the engine. Two observations spoke against it:
- Both CI runs gave the same result per class. CI was repeatable in itself.
- More local runs changed the picture: one of five also returned “no unique helps”.
So this was not “CI versus local”. The stage had a spot where the result depended on something other than its input, and my machine hit it rarely while CI hit it always.
The clock
The search has a safety clock of ten minutes. It exists for a good reason: a search that never ends should not block a phone or a runner forever. When the clock runs out, the search stops.
That makes the clock an input. A search that is cut off after ten minutes can return a different result than one that finishes, and how far it gets in ten minutes depends on the machine.
The numbers, measured on the real engine. The local runs were limited to two cores:
| Measurement | Value |
|---|---|
| Safety clock | 600 s |
| First search of the unique stage, first measurement | 580.6 s |
| First search round, later runs | 466 to 495 s |
| Second search round | 101 s |
| First round for the Witch on the CI runner | 1120 s |
Locally, the search stayed under the limit, but not by much. On the slower CI runner it ran far past it, got cut off and reported that nothing helps. That also fits the one failing local run out of five: my machine was running several other jobs that day, and a round that normally takes 470 seconds does not need much extra load to cross 600. That last part is my reading; I did not measure the load during that run.
Measured is not proven
After the first measurement I had a plausible story: 580.6 of 600 seconds locally, a slower runner, done. I did not accept it yet, for one reason: that number was not split by round, and the clock counts per search round. If the rounds had been 290 seconds each, the story would have been wrong.
So the next step was not the fix, but a log line: the duration of every search round. It showed 466 seconds for the first round and 101 for the second. The first round alone was close to the limit. I added a unit test that checks the round times end up in the log, because that line is now part of how I debug this stage.
The final proof came from CI itself. The next precompute run logged its round times, and the Witch’s first round took 1120 seconds on the runner. That is almost twice the old limit. No guessing left.
The fix, and what is not the fix
The fix changed how the clock applies to this stage and bumped the rule version to 13. The best builds are computed per rule version, so the precompute run started again under the new one instead of mixing results from both clock rules.
Only after that did I make the search faster. That order matters. A faster search would have pushed my machine further from the limit and CI maybe just under it, and the bug would have come back with the next slower runner or the next larger item pool. Speed moves the edge, it does not remove it.
The speedup itself was a separate piece of work. A measurement run showed that 478 of 507 seconds went to one place, and a cache there brought the stage from 824 to 678 seconds in my own run, with an identical result. Two things I checked before I merged it:
- The result with the cache is the same as without it, on the real engine.
- The tests notice when the cache is switched off. I disabled it on purpose, and two tests failed. A cache test that passes with the cache off tests nothing.
I also moved the unique tests into their own CI group, which makes every pull request about five minutes shorter.
What I take from it
Three rules I now apply to every computation that has to be repeatable:
- A wall-clock limit inside a deterministic computation is an input. If it can change the result, it belongs in the result: either the run fails loudly when the clock fires, or the output says it was cut off. Returning a normal-looking “nothing found” is the worst option.
- Three identical local runs prove little. They prove the result is stable on that machine at that load. The fifth run and the slower machine were the ones that mattered.
- Log the unit the limit counts in. My first number was one total, the limit counted per round. Without the per-round log I would have had a story, not a cause.
Where does a timeout decide the result in your pipeline without telling you?