[issue29461] Experiment usage of likely/unlikely in CPython core

2017-06-27 Thread STINNER Victor
STINNER Victor added the comment: So, I played with likely/unlikely and... nothing, nothing interesting. Please use PGO compilation ;-) -- resolution: -> out of date stage: -> resolved status: open -> closed ___ Python tracker

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread Serhiy Storchaka
Serhiy Storchaka added the comment: I also always wanted to experiment this change. But I was afraid that providing such macros can encourage of overusing it. I don't want to wrap any test for NULL or -1 with these macros. If we expect some benefit from using these macros, I would play with th

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread Christian Heimes
Christian Heimes added the comment: I would expect that PGO/LGO builds give better improvements with less coding bloat. Did you compare a PGO likely/unlikely build against a standard PGO build? -- ___ Python tracker

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread Raymond Hettinger
Raymond Hettinger added the comment: I had read that likely/unlikely were hard to use well and often not worth the trouble. IIRC, they are used extensively in the Linux kernel but people were finding zero measurable effect when enabling or disabling the constructs. -- nosy: +rhetting

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread STINNER Victor
STINNER Victor added the comment: Benchmarks with Python compiled by gcc -O3 (without PGO). haypo@smithers$ ./python -m perf timeit 'len("abc")' --duplicate=1000 --compare-to=../default-ref/python Median +- std dev: [ref] 40.4 ns +- 0.8 ns -> [likely] 40.8 ns +- 2.1 ns: 1.01x slower (+1%) hay

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread STINNER Victor
STINNER Victor added the comment: http://blog.man7.org/2012/10/how-much-do-builtinexpect-likely-and.html Using __builtin_expect() in a very long loop 10^9 iteratos (1,000,000,000) makes the loop 15% faster (2.67 sec => 2.28 sec), *but* using PGO avoids the need of using __builtin_expect() exp

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread Christian Heimes
Changes by Christian Heimes : -- nosy: +christian.heimes ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https:

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread STINNER Victor
STINNER Victor added the comment: Copy of msg287111 (issue #29460), Serhiy Storchaka (serhiy.storchaka): > The next question might it: would it be worth it to try using unlikely() > macro on (kwargs == NULL) test in the macro? ;-) Perhaps this may help in some critical tight loops (in implement

[issue29461] Experiment usage of likely/unlikely in CPython core

2017-02-06 Thread STINNER Victor
New submission from STINNER Victor: Attached patch is an attempt to use the GCC/Clang __builtin_expect() attribute to provide the compiler with branch prediction information, it adds _Py_likely() and _Py_unlikely() macros, similar to the Linux kernel macros. I always wanted to experiment this