Why are globals set to tls by default? and why is fast code ugly by default?

Nick Treleaven nick at geany.org
Fri Mar 31 10:42:14 UTC 2023


On Monday, 27 March 2023 at 08:44:41 UTC, wjoe wrote:
> e.g.: It used to be faster to ...
>
> - pre-calculate sin/cos tables, now the memory look up cost 
> more cycles than the calculation itself
>
...
> - only redraw the parts of the screen that changed, now the 
> branching is slower than to  redraw everything

Good to know, thanks.

> another example is sorting - Alexei wrote a blog post about how 
> a stupid and slow sorting algorithm now performs better in 
> multi threading. Maybe someone remembers the title/url of the 
> post ?

Not sure, but that reminds me of Andrei's blog on partitioning 
(for quicksort):
https://dlang.org/blog/2020/05/14/lomutos-comeback/

The algorithm traditionally considered slower can be faster 
because it can be optimized to work better with branch prediction.


More information about the Digitalmars-d-learn mailing list