TE
TechEcho
StartseiteTop 24hNeuesteBesteFragenZeigenJobs
GitHubTwitter
Startseite

TechEcho

Eine mit Next.js erstellte Technologie-Nachrichtenplattform, die globale Technologienachrichten und Diskussionen bietet.

GitHubTwitter

Startseite

StartseiteNeuesteBesteFragenZeigenJobs

Ressourcen

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. Alle Rechte vorbehalten.

Link Time Optimizations: New Way to Do Compiler Optimizations

39 Punktevon signa11vor 6 Tagen

10 comments

WalterBrightvor 3 Tagen
Link time optimizations were done in the 1980s if I recall correctly.<p>I never tried to implement them, finding it easier and more effective for the compiler to simply compile all the source files at the same time.<p>The D compiler is designed to be able to build one object file per source file at a time, or one object file which combines all of the source files. Most people choose the one object file.
评论 #44056616 未加载
评论 #44053764 未加载
评论 #44057594 未加载
评论 #44055044 未加载
评论 #44060940 未加载
Deukhoofdvor 3 Tagen
What do you mean, new? LTO has been in GCC since 2011. It&#x27;s old enough to have a social media account in most jurisdictions.
评论 #44053525 未加载
评论 #44053789 未加载
mcdeltatvor 3 Tagen
Different .c&#x2F;.cpp files being a barrier to optimisation always struck me as an oddly low bar for the 21st century. Yes I know the history of compilation units but these days that&#x27;s not how we use the system. We don&#x27;t split code into source files for memory reasons, we do it for organisation. On a small&#x2F;medium codebase and a decent computer you could probably fit dozens of source files into memory to compile and optimise together. The memory constraint problem has largely disappeared.<p>So why do we still use the old way? LTO seems effectively like a hack to compensate for the fact that the compilation model doesn&#x27;t fit our modern needs. Obviously this will never change in C&#x2F;C++ due to momentum and backwards compatibility. But a man can dream.
sakexvor 3 Tagen
Maybe add the date to the title, because it&#x27;s hardly new at this point
评论 #44053318 未加载
phkahlervor 3 Tagen
I tried LTO with Solvespace 4 years ago and got about 15 percent better performance:<p><a href="https:&#x2F;&#x2F;github.com&#x2F;solvespace&#x2F;solvespace&#x2F;issues&#x2F;972">https:&#x2F;&#x2F;github.com&#x2F;solvespace&#x2F;solvespace&#x2F;issues&#x2F;972</a><p>Build time was terrible taking a few minutes vs 30-40 seconds for a full build. Have they done anything to use multi-core for LTO? It only used one core for that.<p>Also tested OpenMP which was obviously a bigger win. More recently I ran the same test after upgrading from an AMD 2400G to a 5700G which has double the cores and about 1.5x the IPC. The result was a solid 3x improvement so we scale well with cores going from 4 to 8.
评论 #44053909 未加载
Remnant44vor 3 Tagen
Link time optimization is definitely not new, but it is incredibly powerful - I have personally had situations where the failure to be able to inline functions from a static library without lto cut performance in half.<p>It&#x27;s easy to dismiss a basic article like this, but it&#x27;s basically a discovery that every Junior engineer will make, and it&#x27;s useful to talk about those too!
评论 #44054807 未加载
jordiburgosvor 3 Tagen
Any idea on the performance improvements with these LTO?
lilyballvor 3 Tagen
ffmpeg has a lot of assembly code in it, so it&#x27;s a very odd choice of program to use for this kind of test as LTO is presumably not going to do anything to the assembly.
djmipsvor 3 Tagen
So slow
kazinatorvor 3 Tagen
LTO breaks code which assumes that the compiler has no idea what is behind an external function call and must not assume anything about the values of objects that the code might have access to:<p><pre><code> securely_wipe_memory(&amp;obj, sizeof obj); return; } </code></pre> Compiler peeks into securely_wipe_memory and sees that it has no effect because obj is a local variable which has no &quot;next use&quot; in the data flow graph. Thus the call is removed.<p>Another example:<p><pre><code> gc_protect(object); return } </code></pre> Here, gc_protect is an empty function. Without LTO, the compiler must assume that the value of object is required for the gc_protect call and so the generated code has to hang on to that value until that call is made. With LTO, the compiler peeks at the definition of gc_protect and sees the ruse: the function is empty! Therefore, that line of code does not represent a use of the variable. The generated code can use the register or memory location for something else long before that line. If the garbage collector goes off in that part of the code, the object is prematurely collected (if what was lost happens to be the last reference to it).<p>Some distros have played with turning on LTO as a default compiler option for building packages. It&#x27;s a very, very bad idea.