def-pri-pub
Re:Even Faster Asin() Was Staring Right at Me
on Monday March 16, 2026 @12:22PM (#47401059)
>> It also gets in the way of elegance and truth.
Where did that come from in the article?
Re:Even Faster Asin() Was Staring Right at Me
on Monday March 16, 2026 @10:27AM (#47399521)
Thank you for linking that!
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:30PM (#47339337)
The reason for writing out all of the x multiplications like that is that I was hoping the compiler detect such a pattern perform an optimization for me. Mat Godbolt's "Advent of Compiler Optimizations" series mentions some of these cases where the compiler can do more auto-optimizations for the developer.
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:26PM (#47339292)
I did see that, but isn't the vast majority of that page talking about acos() instead?
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:23PM (#47339237)
I did scan some (major) open source games and graphics related project and found a few of them using `std::asin()`. I plan on submitting some patches.
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:21PM (#47339211)
Thanks!
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:20PM (#47339200)
When I was working on this project, I was trying to restrict myself to the architecture of the original Ray Tracing in One Weekend book series. I am aware that things are not as SIMD friendly and that becomes a major bottle neck. While I am confident that an architectural change could yield a massive performance boost, it's something I don't want to spend my time on.
I think it's also more fun sometimes to take existing systems and to try to optimize them given whatever constraints exist. I've had to do that a lot in my day job already.
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:17PM (#47339159)
You'd be surprised how it actually is worth the effort, even just a 1% improvement. If you have the time, this is a great talk to listen to: https://www.youtube.com/watch?v=kPR8h4-qZdk
For a little toy ray tracer, it is pretty measly. But for a larger corporation (with a professional project) a 4% speed improvement can mean MASSIVE cost savings.
Some of these tiny improvements can also have a cascading effect. Imagining finding a +4%, a +2% somewhere else, +3% in neighboring code, and a bunch of +1%s here and there. Eventually you'll have built up something that is 15-20% faster. Down the road you'll come across those optimizations which can yield the big results too (e.g. the +25%).
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @02:11PM (#47339101)
Funny enough that fdlimb implementation of asin() did come up in my research. I believe it might have been more performant in the past. But taking a quick scan of `e_asin.c`, I see it doing something similar to the Cg asin() implementation (but with more terms and more multiplications, which my guess is that it's slower). I think I see it also taking more branches (which could also lead to more of a slowdown).
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @01:43PM (#47338729)
These are books that my uni courses never had me read. I'm a little shocked at times at how my degree program skimped on some of the more famous texts.
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @01:41PM (#47338692)
Wait, what? Do you have a resource I could read up on about that? That is moderately concerning if your math isn't portable across chips.
Re:Faster asin() was hiding in plain sight
on Wednesday March 11, 2026 @11:33AM (#47336962)
> floating point bithacks
The forbidden magic