Thursday, December 29, 2022

It’s Often Memory That’s Killing Your Performance

Rob Napier:

My first mistake was trying to make it parallel before I pulled out Instruments. Always start by profiling. Do not make systems parallel before you’ve optimized them serially. Sure enough, the biggest bottleneck was random number generation.


Huge amounts of time were spent in retain/release. Since there are no classes in this program, that might surprise you, but copy-on-write is implemented with internal classes, and that means ARC, and ARC means locks, and highly contended locks are the enemy of parallelism.


I rewrote update and all the other methods to take two integer parameters rather than one object parameter and cut my time down to 9 seconds [from 40].

Steve Canon:

pet peeve: using “big-O” to refer to abstract algorithmic complexity. Big-O is the technique of looking at the leading term and ignoring constant factors. It is usually the right tool to analyze memory use or cache misses as well!


Comments RSS · Twitter · Mastodon

Leave a Comment