small devlog from my civilization sim. every person runs their own little pipeline each tick (perceive, decide, act, body upkeep, learning, family stuff), so the cost grows with how many people are near each other, not just how many exist.
the worst case i bench on purpose: run a normal world to tick 9000, then drop 3,000 extra people in 60 clusters around the busiest spot. a tick goes from about 3.5 ms to somewhere between 300 and 600 ms.
the part i actually wanted to write about is measuring it, because wall clock time lied to me constantly on a busy laptop:
- count instructions retired and cycles from hardware counters instead of timing it, and compare against a baseline binary built from the same base commit
- take the minimum of several runs, and interleave the a and b runs so background load hits both
- fewer instructions isn't enough, cycles have to drop too. code layout alone can move cycles a few percent, so anything under about 3% i treat as noise
- for the crowd case, measure the run to tick 9020 with the spawn and subtract the run to tick 9000 without it, so you only count the crowd
when you profile, inclusive time per function is where to look first. most of the cost is spread over the per-person pipeline, not one hot leaf you can fix in an afternoon.
how do you all bench worst-case crowds in your own games? do you build a synthetic stress scene like this, or record a real save that got slow?
the sim runs in the browser: https://thehumanbox.com/?utm_source=reddit&utm_medium=social&utm_campaign=devblogs
code and the full notes (docs/DEVELOPMENT.md), mit: https://github.com/1homsi/thehumanbox