6 ms·
Advent of Compiler Optimisations 2025
- filosofo_rancio 11mo agoThanks for sharing, I've always found optimizing a really interesting field, I will keep a close eye!
- ktallett 11mo agoThis is really cool. Congrats on the quality of the work!
- squater 11mo agoYou can never have too much Godbolt!
- bspammer 11mo agoI really appreciate that despite being an obvious domain expert, he’s starting with the simple stuff and not jumping straight into crazy obscure parts of the x86 instruction set
- adev_ 11mo agoMatt Godbolt is an absolute gem for the C & C++ community. Many thanks to him for that. Between that and compiler explorer, it is fair to say he made the world a better place for many of us, developers.
- cyberax 11mo agoWait?!? Godbolt is actually a real person!?!?
- ubj 11mo agoThis is apparently such a common misunderstanding that it was put at the bottom of the C++ iceberg: https://victorpoughon.github.io/cppiceberg/ https://victorpoughon.github.io/cppiceberg/
- cyberax 11mo agoI used godbolt.org dozens of times, and I never bothered to look at "about". D'Oh. Sponsoring him on Github right now...
- mattgodbolt 11mo agoI _think_ so, but this could all be some kind of simulation, I guess? :)
- alfanick 11mo agoIs there a PDF somewhere? I'm not really able to follow YT videos.
- philipportner 11mo agoThere's a link to the AoCO2025 tag for his blog posts in the op.
- alberth 11mo agoAfter 25-years of software development, I still wonder whether I’m using the best possible compiler flags.
- cogman10 11mo agoWhat I've learned is that the fewer flags is the best path for any long lived project. -O2 is basically all you usually need. As you update your compiler, it'll end up tweaking exactly what that general optimization does based on what they know today. Because that's the thing about these flags, you'll generally set them once at the beginning of a project. Compiler authors will reevaluate them way more than you will. Also, a trap I've observed is setting flags based on bad benchmarks. This applies more to the JVM than a C++ compiler, but never the less, a system's current state is somewhat random. 1->2% fluctuations in performance for even the same app is normal. A lot of people won't realize that and ultimately add flags based on those fluctuations. But further, how code is currently layed out can affect performance. You may see a speed boost not because you tweaked the loop unrolling variable, but rather your tweak may have relocated a hot path to be slightly more cache friendly. A change in the code structure can eliminate that benefit.
- 201984 11mo agoWhat's your reason for -O2 over -O3?
- cogman10 11mo agoHistorically, -O3 has been a bit less stable (producing incorrect code) and more experimental (doesn't always make things faster). Flags from -O3 often flow down into -O2 as they are proven generally beneficial. That said, I don't think -O3 has the problems it once did.
- 201984 11mo agoThanks
- 11mo ago
- NooneAtAll3 11mo agoI don't understand where is the problem to be solved?
- eapriv 11mo agoThe problem is “to add two numbers”. The meta-problem is “to learn how computers work”.
- azundo 11mo agoI think they're expecting a daily problem set like Advent of Code. This is not a set of problems to solve, it's a series with one release per day in December, similar to an Advent calendar.
- ketanmaheshwari 11mo agoI am personally interested in the code amalgamation technique that SQLite uses[0]. It seems like a free 5-10% performance improvement as is claimed by SQLite folks. Be nice if he addresses it some in one of the sessions. [0] https://sqlite.org/amalgamation.html https://sqlite.org/amalgamation.html
- theresistor 11mo agoThis is a pretty standard topic, and not really a compiler optimization. It's usually called a unity build. [0] https://en.wikipedia.org/wiki/Unity_build https://en.wikipedia.org/wiki/Unity_build
- nickelpro 11mo agoUnity builds have been largely supplanted by LTO. They still have uses for build time improvements in one-off builds, as LTO on a non-incremental build is usually slower than the equivalent unity build.
- Sponge5 11mo agoAt my company, we have not seen any performance benefits from LTO on a GCC cross-compiled Qt application. GCC version: 11.3 target: Cortex-A9 Qt version: 5.15 I think we tested single core and quad core, also possibly a newer GCC version, but I'm not sure. Just wanted to add my two cents.
- o11c 11mo agoI would expect a little benefit from devirt (but maybe in-TU optimizations are getting that already?), but if a program is pessimized enough, LTO's improvements won't be measurable. And programs full of pointer-chasing are quite pessimized; highly-OO code is a common example, which includes almost all GUIs, even in C++.
- gpderetta 11mo agoDo you link against a version of the Qt library that provides IR objects? In any case even with whole program optimization, O would expect that effectively devirtualizing an heavily object oriented application to be very hard.
- calibas 11mo agoAdvent of Computer Science Advent Calendars, Day 2
- drob518 11mo agoSeems we’ve reached that point.
- bkallus 11mo agoI hope he ends up covering integer division by constants. The chapter on this in Hacker's Delight is really good but a little dense for casual readers.
- atgreen 11mo agoI'm looking forward to the remaining posts. The first thing I did this AM was teach SBCL how to optimize `(+ base (* index scale))` and `(+ base (ash index n))` patterns into single LEA instructions based on the day 2 learnings.
- adamgordonbell 11mo agoMatt is amazing. After checking out his compiler optimizations, maybe check out the recent interview I did with him. What I’ve come to believe is this: you should work at a level of abstraction you’re comfortable with, but you should also understand the layer beneath it. If you’re a C programmer, you should have some idea of how the C runtime works, and how it interacts with the operating system. You don’t need every detail, but you need enough to know what’s going on when something breaks. Because one day printf won’t work, and if the layer below is a total mystery, you won’t even know where to start looking. So: know one layer well, have working knowledge of the layer under it, and, most importantly, be aware of the shape of the layer below that. https://corecursive.com/godbolt-rule-matt-godbolt/ https://corecursive.com/godbolt-rule-matt-godbolt/ Also this article in acmqueue by Matt is not new at all, but super great introduction to these types of optimizations. https://queue.acm.org/detail.cfm?id=3372264 https://queue.acm.org/detail.cfm?id=3372264
- Insanity 11mo agoThe “understand one layer below where you work” is something my professors at uni told us 10+ years ago. Not sure where that originated from, but I really think that benefited me in my career. I.e understanding the JVM when dealing with Java helped optimize code in a relatively heavyweight medical software package. And also, it’s just fun to understand the lower layers.
- kaladin-jasnah 11mo agohttps://cacm.acm.org/research/always-measure-one-level-deeper/ https://cacm.acm.org/research/always-measure-one-level-deepe... This has been a classic repeat in my grad classes.
- mattgodbolt 11mo agoAwww thanks again Adam :blush:
- rramadass 11mo agoMy standard question to all Experts ;-) What are some articles/books/videos that you would recommend to go from beginner-to-expert in your domain ?
- badmonster 11mo ago[flagged]