3 ms·
Its common sense: anything passed in registers(preloaded due spec execution) will outperform stack writes and stack wrangling will outperform heap allocated st
by countWSS 3y ago
Its common sense: anything passed in registers(preloaded due spec execution)
will outperform stack writes and stack wrangling will outperform heap allocated stuff.
That why ugly spaghetti code with tons of globals runs blazingly fast and
your elegant recursive functions and tuple/struct/lists arguments are incredibly slow, the first one
is much easier to optimize into tight assembly loops.
- japanman185 3y agoBut what about my academic mental exercise. You mean I learned all these tools and techniques for nothing? How will my manager know if I am a top engineer or not if my code is not impenetrable with ridiculous concepts applied irrationally.
- Culonavirus 3y agoHalf of the money in IT right now is flowing from investors hearing "blahblah AI blahblah" and seeing dollar bills, which in turn makes half of the movement in IT happen in shitty python code. shrugs
- johnnyanmac 3y agoDifferent scale, different problem. Those "top engineers" at Google are dealing with memory that won't even fit in a hard drive (let alone memory), so stuff like this may as well be pico-optimizations. The logic makes sense for them. The problem is everyone else copying Google without understanding their own data. Any domain where real time performance is important need to put aside the SWE books and pick up a CPU/GPU architecture reference instead.
- eru 3y agoOf course, that assumes that your spaghetti code implements the same algorithm as your elegant code. If the elegant code is O(n) and the spaghetti code is O(n^2) you might notice the difference. And, of course, there's also maintenance to consider. In some sense, compiler are there exactly to turn our elegant solutions into spaghetti code.
- vitiral 3y agoI think that was implied
- gpderetta 3y agoThen again these days some CPUs can rename memory, making stack spills cheaper. Global objects also hinder compiler optimizations.
- mort96 3y ago"Pass parameters in registers, not on the stack" is "common sense". "Parameters larger than 16 bytes are always passed on the stack" ... isn't nearly as obvious.