Kirino 的游戏宝藏
← Back to issue 022
Game observation

Spikes Inside the Test Harness: How Ivan Larin’s Three Days of Experiment Quality Raised FPS for *Brotato* on Weak Hardware

If, for more than a decade, indie game optimization has defaulted to “stare at the profiler, rewrite a pile of code, then glance at whether average FPS looks nicer,” then the…

Saved articles ↗

If, for more than a decade, indie game optimization has defaulted to “stare at the profiler, rewrite a pile of code, then glance at whether average FPS looks nicer,” then the trade-off Ivan Larin posted on DEV on 20 October 2026 nearly rewrites that default script in public. Three days building a test harness returned more usable frame rate than nearly a month he had spent writing optimization code.

I cross-checked the English piece titled *Game Optimization Methodology* with his Russian original on Habr. The mechanisms, scenario setups, and numbers below all come from the author’s public account. This article does not claim access to his project source, and it does not pretend to be a playtest review. Larin is a mobile game developer who mostly does gameplay programming and team tools, and likes Godot, Lua, and C++. What follows is one measurement experiment from a hobby project.

The image that runs through this piece is the test harness itself, and the two ways of reading it forces. One reading uses the average and sandpapers spikes flat. The other keeps median, P95, P99, and worst value, and leaves the spikes on the chart. It can sound like a methodology habit. On the ethics of production, it becomes a willingness to pay for experiment quality first, then decide whether the next line of code is worth writing.

A high-wave Brotato scene, enemies and projectiles crowding the same frame budget

1. Default logic: optimization means finishing the next code pass faster

Industry default logic is clean, and therefore cheap.

When a game drops frames, teams usually open a familiar menu. Turn on the profiler, guess the hot path, change physics, batching, or resolution, play two runs, then check whether average FPS rose. Players learn the same vocabulary for reading optimization posts. They ask how many frames were gained, and whether the average holds. That shared habit makes coding speed the loudest lead in the optimization story, while experiment design is treated as preparation that can wait.

*Brotato* pushes that grammar to its limit. It is an indie game about a potato with guns, leveling up, and clearing endless enemies. Hardcore players can reach wave 1000 and beyond. For more casual play the practical ceiling sits around waves 150–200, with roughly six thousand enemies in a single wave. On desktop PCs this is rarely painful. On handhelds and weak devices the game is extremely popular, because simple controls and a casual tone fit play on the go. When Larin played on an Anbernic RG34XXSP, FPS fell to 5–10 from about wave 20. The goal he wrote down was deliberately plain. Make the game playable again on hardware that previously struggled, while changing original scripts as little as possible so future updates would not wipe the work. The final patch to original source stayed under two hundred lines.

The fork sits here. Keep asking how to write the next optimization faster, and you are shopping for a cheaper seat inside the same tax schedule. Ask instead whether this measurement can honestly compare two builds, and you admit the tax lines themselves can be rewritten. Larin already had mobile optimization experience, yet in Stage 1 he still skipped the boring prep and started with a hasty harness. Later numbers show that the prep he saved was re-invoiced as a full month of code.

Anbernic RG34XXSP specs, Larin’s first weak-hardware target

2. How a hasty harness buried real gains in noise

Stage 1 can be reconstructed in concrete beats. The potato spawned on wave 100 with a fixed seed. The harness logged frame time, draw calls, and collision-pair counts every frame, then wrote arithmetic means to a file at the end. After several console runs and a few debugger sessions on PC, the picture was not wild. The main bottleneck was collision work inside Godot’s physics server. Pair counts were huge, and halving physics TPS confirmed it. The secondary bottleneck was draw calls and GPU state changes. Textures lived in separate files and broke batching. Scripts also cost time, but profiler overhead made a specific hot path hard to nail.

He acted on that picture. On the physics side he tried replacing the engine path with a hash grid rebuilt every frame, SoA position/size storage, and a simplified solver. Brotato uses only circles for collision shapes, and a hash grid is easier to write than the default BVH, so he first built a GDScript proof of concept, planning a C++ plugin if results looked good. Rendering looked simpler. Merge textures into one atlas, bake fonts to bitmaps, and let resource switches happen only between layers so Godot could batch.

Weeks later, as the result neared completion, the console died. Larin jokes that Anbernic’s cheap power controllers deserve thanks. Without target hardware, enthusiasm cooled. He still finished the custom physics and batching scripts, saw the gain he wanted to see, and moved on. Later he remembered the project and retested optimized and clean builds on a Samsung A51, a phone that was already weak when it launched in 2019. The retest was cold. Gains sat roughly inside measurement noise.

Stage 2 became an error list. No run metadata, so two recordings could not be verified as comparable. No dry runs, so cache warm-up, early shader compile, and thermal state on mobile never aligned. Wall-clock duration controlled the test. When FPS fell, Godot could execute fewer physics ticks per rendered frame, distorting the simulation while lightening the load. Stopping by physics-tick count keeps work equal. A single scenario meant he optimized that one playthrough, not the game. Raw metrics were not saved, so any later change in processing invalidated old results. Arithmetic mean as the main figure let outliers yank the typical value sideways.

He decided to start over, this time pouring most effort into a proper harness so every change could be seen objectively. Stage 1’s custom physics and atlas work were not instantly disproved. They were only shown first to applaud themselves under crooked measurement.

Stage 1 results assembled in a hurry after the console died; gains later failed to match on the A51

3. Three days of harness and spikes: how experiment quality lifted the real causes

The second attempt spanned about five days, three of them spent building the harness. The in-game testing system was the bulk. A scenario system could reproduce any game state quickly. A runner configured recorded runs and dry runs. Metrics logged chosen values every frame. A test HUD showed live numbers. A build plugin wrote the Git commit into the build. A recording system saved results, scenario configs, and build metadata to disk after all tests finished.

Data processing moved to an external script. Inside one run he took median, P95, P99, and worst value. The median holds the typical figure and barely moves for outliers. P95 and P99 hold rarer bad values. The script then estimated variance and drew the final graph, aiming to make anomalies visible instead of burying them in an average. Compare mode checked metadata on two recordings and, only when comparison was valid, computed relative change for every metric.

The difference on the chart was immediate. FPS drops arrived as spikes. A uniformly lowered average was rarer. Spikes usually came from the physics server failing to finish the required ticks inside one rendered frame. So the main goal became remove spikes first, then raise median FPS. The harness was not only software. A Samsung A51 hung off the PC over ADB. Tests ran on the phone automatically, and data came back for analysis. The same loop could have run on the RG34XXSP; Larin learned about MuOS ADB mode too late. Once a real-device loop is cheap, handing it to an AI agent also becomes realistic. The premise remains that measurement itself is not crooked.

Three scenarios locked the comparison axis. First, wave 200 with six slingshots and damage multiplied by one million, testing a boss wave (waves divisible by 20) with player damage close to real play. Second, wave 249 with the same loadout, mainly to catch regressions on non-boss waves. Third, an AFK test on wave 150, simulating a low-damage, survivability-heavy build.

Test scenario configuration UI; the runner can set recorded runs and dry runs

Old solutions showed their true shape under the new harness. The custom physics replacement not only failed to help; it made scenarios 1 and 2 worse. Rendering optimizations showed almost no effect. Larin judged that physics still dominated the whole frame, so batching was postponed. The harness’s first successful receipt did not say +FPS. It recorded the real impact of the old fixes.

Then he ran again with the debugger, hunting abnormal paths. Looking at function time in the usual way was mostly useless. The game calls a huge number of tiny functions, and instrumentation overhead warped reported times. He switched to call counts. Suspicious candidates were disabled first to see whether performance improved, then the loop repeated until the bad path was pinned.

The real causes were much plainer than custom physics. Enemy hitboxes and collision areas were not layered apart, so the broad phase produced huge numbers of invalid enemy–enemy pairs when the pairs that mattered were player–enemy. The fix was short: move enemy hitboxes to a separate layer. Small script inefficiencies also surfaced. A static map size was recalculated every frame. Fire-spread collision queries ran for characters that were not burning. Already-disabled collision areas were disabled again every frame. A few guards cleared them. The BVH versus hash contrast was more interesting. Godot’s physics server defaults to BVH for broad phase; Brotato’s developers had already switched to a hash grid, which Larin did not know in Stage 1. Switching back to BVH helped the AFK scenario most and slightly hurt the slingshot scenarios. Because the gain in scenario 3 dwarfed the regressions in 1 and 2, he kept BVH.

Against vanilla, taking the median of each scenario’s per-run median FPS, the numbers were these. W200 went from 16.08 to 32.30, about +100.8%. W249 went from 45.33 to 51.95, about +14.6%. AFK went from 14.02 to 44.02, about +214%. A couple of lines of optimization code and a few hours of testing bought the playability that a month of custom physics had not delivered.

Run analysis graph: drops show as spikes, and the average no longer sandpapers the jitter

Later physics hypotheses stopped producing positive results. Scenario 3 was about 80% physics-bound, so he turned to scenarios 1 and 2. The main hypothesis remained bandwidth and constant state switching. Two quick checks. Resolution cut to 25% ruled out GPU fill-rate pressure and gave no gain. Hiding enemy rendering gave about +50% FPS. Once physics dominance was torn open, batching mattered again. In RenderDoc he found an object group missed in round one: blood effects. Stage 1 had barely tested a scenario where enemies were actually being shot, and blood accounted for about 30% of all draw calls. After reading the docs, particles moved to MultiMeshInstance2D, a separate layer drawing every droplet in one command. Old batching plus the blood change took W200 from 32.30 to 40.11 and W249 from 51.95 to 55.7. AFK improvement sat inside error and was left out of the table. He stopped. The next cut would cost much more development time, and further scraping was no longer worth it.

Blood moved to a single MultiMeshInstance2D layer

Close: indie means willingness to pay for experiment quality first

Put this October essay back into the indie production floor of autumn 2026, and what it hits first is a quiet production habit. People default to writing code first when optimizing, and often default to average FPS as a stand-in for how a game feels. The test harness is treated as boring prep worth doing only two weeks before ship, and few people ask further. When you are already down to single-digit FPS on weak hardware, what is expensive: the next line of custom physics, or the measurement habit that forces you to applaud yourself with noise?

For small teams this material is especially useful. You need not rewrite Godot’s physics server, and you may have no interest in wiring an ADB loop into a hobby project. You almost certainly have your own “already good enough” list. An optimization that starts because a profiler bar turned red. A comparison that declares victory after one run. A metric that uses only the arithmetic mean. A scenario that is always the wave you know best. Larin writes the cost in plain dirt. Three days of harness. Run metadata. Dry runs. Stop by physics tick. Median and spikes. Separate enemy hitbox layers. A few guards. One MultiMesh blood layer. Under two hundred lines changed in the original game. What costs is willingness to pay for experiment quality first, then let coding speed serve comparable hypotheses, and willingness to admit on the receipt that when measurement is crooked, a hundred AI iterations only do more harm.

Executable notes, kept short.

  • Write your must-be-comparable list first. Which three kinds of change become instantly untrustworthy without metadata, dry runs, and a fixed-work stop condition. Those enter the harness before they enter the inspiration notepad.
  • Prepare at least two scenarios. One close to real high pressure, another dedicated to catching regressions. Physics-bound and render-bound cases are best seen apart. Single-scenario work easily optimizes only that one run.
  • Make the median your main figure, and watch P95, P99, and worst together. Let spikes show on the chart. Average stays supporting evidence.
  • For suspicious hot paths, look at call counts first, then disable-and-compare. Instrumented timings often lie in a sea of tiny functions.
  • Accept physics and rendering in layers. While physics dominates, batching may be invisible. Tear open the dominant term first, then measure secondary wins.
  • Check collision layers and query guards early. Invalid pairs, per-frame recalculation, and repeated disable are often cheaper and more real than a custom solver.
  • Write the stop condition in plain text. Decide how expensive the next development cut must be before you stop, so the harness does not become an infinite self-proof machine.
  • If you hand the test loop to AI, keep measurement straight first. Iteration count amplifies experiment quality, and it also amplifies self-deception inside noise.

Three days of harness, an ADB loop on an A51, a doubled median on wave 200, the blood draw calls missed in round one, and a final patch under two hundred lines of original source. Before store copy turns “AI auto-optimize” into a slogan, the production side has already written the audit standard into a public longform. Let spikes become visible again first, then let the word indie land on a willingness to pay for experiment quality up front.

小光

Sources and further reading

Ivan Larin, DEV Community (2026-10-20), Game Optimization Methodology…

Russian original on Habr

Sign in to keep your reading history.

View your likes and saved articles across devices.

Sign in