digitalmars.D - --inline
- Russel Winder (15/15) Apr 15 2012 I am getting hints that using --inline in some small (well trivial
- bearophile (16/25) Apr 15 2012 Inlining (like most other things in life) is a matter of
- bearophile (9/9) Apr 16 2012 For interested people, there is a thread in D.learn that shows a
- Timon Gehr (2/11) Apr 16 2012
I am getting hints that using --inline in some small (well trivial really) compute intensive codes actually makes performance worse by a few percent. Nothing experimental / statistically significant, just some anecdotal observations. Is this as it might be expected or is it something that needs more investigation? --=20 Russel. =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D Dr Russel Winder t: +44 20 7585 2200 voip: sip:russel.winder ekiga.n= et 41 Buckmaster Road m: +44 7770 465 077 xmpp: russel winder.org.uk London SW11 1EN, UK w: www.russel.org.uk skype: russel_winder
Apr 15 2012
Russel Winder:I am getting hints that using --inline in some small (well trivial really) compute intensive codes actually makes performance worse by a few percent. Nothing experimental / statistically significant, just some anecdotal observations. Is this as it might be expected or is it something that needs more investigation?Inlining (like most other things in life) is a matter of tradeoffs. Inlining removes the costs of function calls, allows some more small local optimizations, and increases code locality in the code cache, but it also increases code size and this sometimes increases cache misses. Finding the right amount of inlining to use is hard. The inliner works heuristically (and often only on the base of information known statically, unless you are using a JIT or profile-driven optimization) to balance such tradeoffs, trying to find something good enough on average. But sometimes its choice is suboptimal. GCC offers user-written compiler hints to forbid the inlining of a specific function, or to almost-force the inlining of the function. Bye, bearophile
Apr 15 2012
For interested people, there is a thread in D.learn that shows a missed inlining in DMD: http://forum.dlang.org/thread/alnkynbdyddtrwpmfngr forum.dlang.org (After that manual inlining the D code is slower still than the same C++ code). I think forceinline is not necessary here, a more aggressive inliner seems enough. Bye, bearophile
Apr 16 2012
On 04/16/2012 03:33 PM, bearophile wrote:For interested people, there is a thread in D.learn that shows a missed inlining in DMD: http://forum.dlang.org/thread/alnkynbdyddtrwpmfngr forum.dlang.org (After that manual inlining the D code is slower still than the same C++ code).I think there was an alternative D translation that was comparatively fast?I think forceinline is not necessary here, a more aggressive inliner seems enough. Bye, bearophile
Apr 16 2012