4 ms·
Very interesting, and that constant folding trick is handy!
by fwsgonzo 2y ago
Very interesting, and that constant folding trick is handy!
- smitty1e 2y agoI was going to label this a fine example of yak shaving. Usually when I'm working this hard against the tool, I've missed something, though the author here sounds expert.
- DrBazza 2y agoThis is the sort of thing we do in HFT to get single instruction calls and save nanos in places that get called many many thousands of times a second.
- smitty1e 2y agoI mean, at some point, why not just write a custom compiler?
- trelane 2y agoIf you care that much, you use intrinsics, asm in the C file, or asm to create an object you call into. Most of the code doesn't need nearly that level of optimization, so you write it in a higher level language. Making your own compiler is a lot of work compared to just doing what I've outlined above. So you don't. I's not worth it, and you'd still end up back where you are.
- TillE 2y agoWriting assembly really isn't that scary, especially in small doses for performance-critical code. That was a very common practice in the 80s/90s, though it's faded as compiler optimizations have improved.