20 FPS! Profiler shows nothing. You’re about to blame Unity!
By Fuat Can Köseoğlu,
But here’s the twist: • Your CPU might be waiting on memory 95% of the time. Access times: • RAM: 100 ns • Cache: 0.5 ns That’s a 200x difference. The CPU fetches 64 bytes at once, betting you’ll use nearby data. If you don’t? Performance tanks. The culprit (see image): • Dictionaries scatter data everywhere — each iteration is a RAM treasure hunt. • Arrays line up data like dominoes — one chunk = multiple values, the next already preloaded. The profiler won’t show this. It just says: Update(): 4ms But the truth? 3.5ms is the CPU waiting on memory! Fixes that actually work: • Iterate arrays, not dictionaries • Get components once, store locally • Pack similar data together in memory Which "clean" code patterns have secretly killed your performance?