Performance Excuses Debunked

3 Likes

Interesting write up for someone like me who has recently commenced the journey of trying to learn more about what’s happening under the hood and performance. Would you be willing to elaborate more here on one sentence from the conclusion?

“It’s more about learning to read things like assembly language, so you can understand how much actual work you are generating for the hardware when you make each programming decision in a higher-level language”

I’ll throw in a simple example here - take “hello world” for instance. What does hello world actually do to get that text to print on a screen? I understand you write python (that was my first language - still write in it today) so let’s take print for example. What does print actually do - yes it prints text, but what does it actually do?

Does it make a system call? How much memory does it allocate? Is it blocking? What does print("hello world") actually cost in terms of machine labor? We know it has to boil down to machine instructions, but what are those and when can you afford them?

At one point, higher level languages did not exist… We had vacuum tubes and occasionally you’d get a moth stuck in a socket (literally where the term “bug” came from). At some point, we started seeing computers more like what we have today that came with instruction sets that could be reprogrammed using software (and they literally called it software because they believed that “hardware” was harder to change where as software was reprogrammable).

At some point, you could write assembly code - step by step telling one of these computers what to do. People eventually thought that there’s got to be a way to organize some of these common patterns to express our ideas… so we came up with languages like C. Up to that point, it was painfully more obvious what your computer was actually doing.

Today, you can just write print("hello world") and not need to know that - we can be blissfully unaware of what instructions are actually run by that statement. In some ways, that’s insane progress but you can imagine that it allows us to ask for things that are expensive while being unaware of the cost.

I love Casey, I can’t recommend his course enough, where he talks about everything related to performance, how to improve the CPU throughput, by using the cache, or by using SOA, or using SIMD, it’s amazing all you can learn by listening to this guy. For anyone interested in writing performant software this guy is a mine of information.

2 Likes

Now a bit different angle

2 Likes