Performance is one of the properties of a program that the learned developer has a quote at hand to discount – as premature optimisation is the root of all evil (carefully omitting the second part of the quote). The natural consequence is that code is written to be more readable (as code is written once, but read many times), with better variable names (good code is self-documenting) and more reusability (Don’t Repeat Yourself), but as performance is not a concern, it is ignored (or occasionally worked against, preferring developer experience over user experience).

I read a Hacker News post recently talking about Google interviews, and the poster mentioned that Data Structures & Algorithmic knowledge was vital, as this generated most performance improvements. I don’t think that meshes with my experience (I would expect network / IO code), and I have a project at hand to check. About 80% of these came from profiling; the others were from using the program and considering likely issues.

Algorithmic (Needless Work)

Algorithmic (Bulk Updates)

  • defer GearChangeFrame updates – when getting current equipment, instead of setting each piece individually and updating the frame at the time, set each piece and then update the frame in bulk. This is sort of algorithmic but isn’t the standard Big O improvement, but about doing bulk updates instead of individual ones
  • read cached data instead of doing an expensive computation – area combat data is stored for each area with a list of monsters, and the function was formerly getting all areas with a particular monster (i.e. reading over every area) and checking if a particular area was present. It’s much faster to just read off the specific area’s combat data (even though that involves a list instead of a set).
  • buffer the mall price output stream instead of flushing every line – buffering leads to an order of magnitude increase in efficiency for file I/O

Algorithmic (Wrong Abstraction)

Data Structures

Other

  • migrate from HTTP/1.1 to HTTP 2 – a massive improvement in speed for users not in the USA, with proportionally better increases the greater the distance. Mostly swapping glue code, with a tiny amount of networking knowledge (HTTP headers are case insensitive)

So in conclusion, I was wrong: data structure specifics were heavily involved in the performance improvements, and while Big O-style algorithms weren’t, concepts like needless work and bulk updates were. Caching also made an appearance.