[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: I've worked on this with Dave Malcolm @PyCon2013 sprints. This patch is work in progress to make Py_XDECREF() and Py_XINCREF() expands their arguments once instead of multiple times. Because patch is work in progress, it contains old version for ease of benchmarking. To enable the old version - define OLD_17206. Tested so far only with: Clang on Mac OS X 10.7 x64. -- keywords: +patch nosy: +ilblackdragon Added file: http://bugs.python.org/file29439/17206.diff ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Additionally, in macros Py_XINCREF and Py_XDECREF we've took an opportunity to increase readability by changing expression: > if (item == NULL) ; else action(item); to more natural inverted condition: > if (item != NULL) action(item); There is a chance that there may be a reason for this form of expression, so let me know if this is an issue. -- nosy: +larry ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Benchmark run on Clang Mac OS X 10.7 attached of comparison with and without patch 17206.diff. -- Added file: http://bugs.python.org/file29440/perf.log ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Command used for benchmarking was: python perf.py -b 2n3 -f ../cpython/baseline-clang/python.exe ../cpython/experiment-clang/python.exe | tee perf.log -- ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2786] Names in traceback should have class names, if they're methods
Illia Polosukhin added the comment: Talked with David Murray (r.david.murray) at @pycon2013 sprints - will try to address this. -- nosy: +ilblackdragon ___ Python tracker <http://bugs.python.org/issue2786> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: That names were my first idea - but then I saw Py_CLEAR uses _py_tmp variable I used it. Should I replace in Py_CLEAR to _py_clear_tmp as well? -- ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue2786] Names in traceback should have class names, if they're methods
Illia Polosukhin added the comment: The issue is not that easy to address - because PyFunctionObject is not available from PyEval_EvalCodeEx. Another note, is that the issue of reporting only function name without class name is observed in many places, not just for example above. Still, will try to make a patch that will address the issue. -- ___ Python tracker <http://bugs.python.org/issue2786> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Compiled baseline and patched version with GCC in Ubuntu 12.10 (running in VMWare). Benchmarking results are attached: ./perf.py -b 2n3 -f ../cpython/baseline/python ../cpython/experiment/python | tee perf-linux.log -- Added file: http://bugs.python.org/file29523/perf-linux.log ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Additionally, disassembled ceval.o and compared baseline with experiment (with applied patch): no actual differences found. Attached archive contains ceval from both baseline and experiment builds: - cevalb.cc - processed file of baseline build - ceval.cc - processed file of experiment build diff ceval.cc cevalb.cc - shows differences introduced by patch. - cevalb.o - object file of baseline build - ceval.o - object file of experiment build - cevalb.asm - disassembly of baseline object file - ceval.asm - disassembly of experiment object file diff ceval.asm cevalb.asm - doesn't show any differences in generated assembly code. -- Added file: http://bugs.python.org/file29524/asmdiff_17206.zip ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Updated patch - removed old code and addded tests to _testcapimoudule.c as Amaury suggested. Amaury, why do you mention -R flag (from what I see it does hash randomization)? I would expect some flag, that would enforce memory leakage issues to fail test. -- Added file: http://bugs.python.org/file29617/17206-2.diff ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Fixed Py_DECREF and Py_CLEAR as well. Added tests for Py_INCREF and Py_XINCREF (if somebody has a better idea how to tests that INCREF doesn't leak - please, let me know). Removed comment that Py_DECREF evaluate it's argument multiple times as not relevant anymore. About considerations from performance point of view - I've made toy example (only this defines and main function) to test how gcc optimizer behaves in different cases - from what I see, if expression is like this (which is majority of cases in the code): PyObject* obj = Foo(); Py_XDECREF(obj) assembly code that will be produced (with -O3) is the same before and after patch. -- Added file: http://bugs.python.org/file29660/17206-3.diff ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue17206] Py_XDECREF() expands its argument multiple times
Illia Polosukhin added the comment: Amaury, I didn't update Py_INCREF macro in this patch (because it doesn't expand it's argument multiple times) - so the examples you are showing will be working fine. I've updated Py_XINCREF, but it can't be used as an expression anyway. -- ___ Python tracker <http://bugs.python.org/issue17206> ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com