Hacker News new | ask | show | jobs
by mwkaufma 780 days ago
I don't understand why half of these aren't optimized by the compiler automatically. (x - y).norm_squared()? Why is f32::clone() not just an inline mov? Begging a lot of questions.
1 comments

I've previously had problems with the compiler not inlining / eliding instructions solely due to profiling code (see a blog post: https://www.jackyoustra.com/blog/llama-ios#-bug-bug-slowdown...). I wonder if it's that?

(I've also always had a sneaking suspicion I did something wrong in my example, so if anyone knows let me know)

Pcwalton’s explanation is much more likely to be correct https://news.ycombinator.com/context?id=41830704

Profiling native code with optimizations on is very very tricky.

What's the point of profiling for performance without optimizations if it leads you where the OP winds up hand rolling the same transformations?
Usually a terrible idea (imo) to profile without optimizations, I think the point is profiling with optimizations is tricky (without much better alternative).
Agree, seems like a more likely culprit in this case.