This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author alecsandru.patrascu
Recipients alecsandru.patrascu, benjamin.peterson, brett.cannon, pitrou, skrah, vstinner, yselivanov
Date 2016-02-04.20:42:44
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1454618564.64.0.0352238694676.issue26285@psf.upfronthosting.co.za>
In-reply-to
Content
I realize now that I should have explained a bit more the background of this patch. I'll do this now, for everyone to be clear of what is the effect of those flags.

This issue was revealed after running the coverage target over various workloads, for both CPython2 and CPython3. After running, it can be observed that there are functions in the interpreter that are not called at all over the lifespan of the interpreter. Even more, these functions occupy space in the resulting binary file, and the CPU is forced to jump to longer offsets than it is required. Furthermore, for production level binaries, it is a good idea to remove these stubs, as they bring no benefit. Now, in order to do this, in the first step, every function or data item must exist in its own section (and the flags -ffunction-sections and -fdata-sections come to help in GCC). In the second step, the linker comes into play and because it has the entire picture of every piece of data or function, it is able to see if there are functions that are never called for the current build (and the flag --gc-sections come to help).

This functionality is not unique or new and are used by default in other interpreters, such as V8/Node.JS in their Release target, to achieve exactly the same goal. Another example for behind the scene usage of this functionality is the Microsoft's compiler, which does it automatically in their interprocedural optimization phase.

To compress all of the above, the main reason for this speedup is the reduction of the code path length and having the useful function close together, so that the CPU will be able to prefetch them in advance and use them instead of trowing them away because they are not used.
History
Date User Action Args
2016-02-04 20:42:44alecsandru.patrascusetrecipients: + alecsandru.patrascu, brett.cannon, pitrou, vstinner, benjamin.peterson, skrah, yselivanov
2016-02-04 20:42:44alecsandru.patrascusetmessageid: <1454618564.64.0.0352238694676.issue26285@psf.upfronthosting.co.za>
2016-02-04 20:42:44alecsandru.patrasculinkissue26285 messages
2016-02-04 20:42:44alecsandru.patrascucreate