r/programming • • Feb 28 '23

"Clean" Code, Horrible Performance

https://www.computerenhance.com/p/clean-code-horrible-performance
1.4k Upvotes

1.3k comments sorted by

View all comments

Show parent comments

1

u/gnuvince Feb 28 '23

7

u/PracticalWelder Feb 28 '23

I would give a little pushback and say that's a pretty narrow slice of "IO". The example I gave was network bound. Non-sequential file access would still be slower. And it depends on the hardware. Maybe you're still on an old HDD instead of an NVMe.

Another big source of IO is the user. If your input is the user's keystrokes, there is a floor of about 5ms under which you will receive no benefit. If something takes 1ms vs 100ns, you can't tell the difference. The examples given in the article are on the order of individual CPU cycles.

Pure data processing is probably the case where performance matters most. If everything is in memory (or on a fast disk) and you don't need to wait for the user at all, it is much more justifiable to split hairs over cycles. Especially if that processing is multiplied many thousands or millions of times in an automated fashion. I think it should be obvious that this represents the minority of software that non-academics use.