4 ms·
I was writing an NMEA parser today. (NMEA 0183 is a common serial GPS data protocol) My serial port reads returned an IOvec-like type which exposed limited oper
by mastax 4y ago
I was writing an NMEA parser today. (NMEA 0183 is a common serial GPS data protocol) My serial port reads returned an IOvec-like type which exposed limited operations. I spent probably an hour making helper functions and doing various verification and parsing operations on the IOvec type because it saved having to copy the data into a contiguous buffer. Midway through I stopped and realized that I would only need to copy when the ~50B message straddled the end of the ~64kB buffer. It takes a few nanoseconds to copy 50B. I spent an hour on an optimization that would never do anything but complicate the code. If I had just written the simple and obvious code, and spent that hour profiling the application to optimize what would actually make a difference, I'd be much better off.
That is what the quote is talking about. I don't think you can blame the quote if people are just ignoring the first word, and I'm not convinced that's actually a common thing.
- userbinator 4y agoIMHO that's better called "premature complexity". You shouldn't even need to profile to realise that if you're using a serial port for I/O, unless your hardware is something embedded and in the low-MHz, range, you'll spend most of your time waiting for I/O unless you massively overcomplicate your solution.
- sicariusnoctis 4y agoNew quote just dropped: Premature complexity is the root of all evil.
- IshKebab 4y agoMaybe you can't blame the quote author but the quote itself is definitely a problem now. In my experience it is mostly used as an excuse not to think about performance at all. "The quote says we can worry about it later!" That's why the quote needs to die.
- kaba0 4y agoOr extended with the context, like “Yet we should not pass up our opportunities in that critical [hot loop]”
- kllrnohj 4y agoThe "hot loop" is also a myth. Very few programs actually have a hot loop with larger-than-average returns on optimizations. Heck, the blog post itself is an example of that not being the case - it's startup that's slow, not the program's steady state hot loop. For something you actually spend a significant amount of time using continuously, yeah maybe it has a hot loop. But even then, probably more like hundreds or thousands of hot loops depending on the features being used, what stage the program is in (eg, blender while editing the scene is very very different from blender while exporting a rendering).
- loup-vaillant 4y agoIn other words: first, understand your data. That's what Mike Acton says before he shakes your hand in the morning.