Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Is there any logical reason why Clang is 50% slower than GCC on Ubuntu?


Hi, I had a look today because it was bugging me and no one had investigated it, so I created an issue[1] with an explanation.

But it basically boils down to uniform_real_distribution having a bunch of uninlined calls to 'logl' when compiled with Clang.

Otherwise, Clang beats GCC at least on the configuration I tested.

(I am the author of the issue)

[1] https://gitlab.com/define-private-public/PSRayTracing/-/issu...


Oh, very nice find!

Coincidentally, I happened to be playing around yesterday with a small performance test case using uniform_real_distribution, and for some strange reason Clang was 6x slower than GCC.

I put it down to some weird clang bug on my LTS version of Ubuntu. As my installed version was clang-14, I decided it possibly had been noticed and fixed a long time ago.

After reading your message I replaced uniform_real_distribution by uniform_int_distribution, and lo and behold, Clang was indeed faster than GCC, as expected.

Thank you for coming back to me with your findings.




Consider applying for YC's Winter 2026 batch! Applications are open till Nov 10

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: