3 ms·
Such a subtle issue! And I lay the blame on our obsession with abstraction. Once we give up responsibility of the machine architecture to a compiler, we then h
by JoeAltmaier 3y ago
Such a subtle issue! And I lay the blame on our obsession with abstraction.
Once we give up responsibility of the machine architecture to a compiler, we then have to chase issues like this. What gestures can I make to my compiler, to make it use better machine operations? It's maddening. Like a game of charades.
Sure abstractions gain us tremendously, are an invaluable aid to quickly conceiving of an application and creating something safe and understandable and even beautiful.
But we lost all hope of making it fast, or small, or 'efficient' in any physical way.
My favorite example from my lifetime: On the Dell Triton our app programmers had a main loop that included a call using complex types. The entry point had, and I disassembled to see, five constructors and destructors called to coerce the types into something the API needed.
It consumed the entirety of the embedded processor hyper-thread. They were unconcerned, as it worked as designed.
I added a little casting in the call arguments, which reduced the CPU time to something like 15%.