DConf 2017: Abstraction Cost and Optimization (LDC) -- Johan Engelen

Опубликовано: 07 Апрель 2026
на канале: The D Language Foundation
106
3

Slides available at https://dconf.org/2017/talks/engelen.....

Discussions about the performance of code fragments pop up regularly on the dlang forums. Why is this much faster than that? Does `immutable` make my code faster? Is a range-based loop faster than a normal loop? Without understanding the LDC optimization process and capabilities, it's not so easy to do good performance measurements and comparisons; the discussions often lack good data.

Using Matt Godbolt's D compiler explorer, I will live demonstrate and explain the optimized LDC assembly output for basic D code patterns. Common pitfalls and how to avoid them will be discussed. A small selection of topics: virtual functions, Voldemort types, aggregate comparisons, when does immutable/const matter?, inline assembly, ranges or for-based iteration. The results are often surprising, so for extra fun, I'll poll the audience before showing the assembly output. After this talk, you'll be better prepared for the next forum.dlang.org performance thread.