[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread INADA Naoki
Changes by INADA Naoki : -- dependencies: -Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects resolution: -> fixed stage: -> resolved status: open -> closed ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread Roundup Robot
Roundup Robot added the comment: New changeset 48bde5d2cc5b9e98f55cd23ee57f3996d81caeb5 by INADA Naoki in branch 'master': Issue #29263: LOAD_METHOD support for C methods https://github.com/python/cpython/commit/48bde5d2cc5b9e98f55cd23ee57f3996d81caeb5 --

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread Roundup Robot
Roundup Robot added the comment: New changeset 135a9a0c09f9 by INADA Naoki in branch 'default': Issue #29263: LOAD_METHOD support for C methods https://hg.python.org/cpython/rev/135a9a0c09f9 -- ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread STINNER Victor
STINNER Victor added the comment: loadmethod-methoddescr-2.patch LGTM. -- ___ Python tracker ___ ___

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread INADA Naoki
Changes by INADA Naoki : Added file: http://bugs.python.org/file46493/loadmethod-methoddescr-2.patch ___ Python tracker ___

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread STINNER Victor
STINNER Victor added the comment: Naoki> I confirmed bm_mako performance degrade is caused by L1 cache miss. I know this performance instability very well, the issue is called "code placement": https://haypo.github.io/journey-to-stable-benchmark-deadcode.html I tried to fight it with GCC

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread INADA Naoki
INADA Naoki added the comment: I confirmed bm_mako performance degrade is caused by L1 cache miss. (I didn't use --with-optimization) https://gist.github.com/methane/b33edbf1f123ae026e704b0e005c3606 -- ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +serhiy.storchaka ___ Python tracker ___

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-02 Thread STINNER Victor
STINNER Victor added the comment: I tried to benchmark b''.decode(encoding='ascii'): CALL_METHOD is not used for this call, but CALL_FUNCTION_KW :-/ So the call is not affected by your patch. I also ran a quick benchmark on loadmethod-methoddescr.patch: b''.decode(): 71.1 ns +- 0.5 ns -> 65.4

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread INADA Naoki
INADA Naoki added the comment: microbench: $ ./python.patched -m perf timeit --compare-to `pwd`/python.default -s "d = b''" -- "d.decode('ascii')" python.default: . 109 ns +- 1 ns python.patched: . 102 ns +- 1 ns Median +- std dev: [python.default] 109

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread INADA Naoki
INADA Naoki added the comment: Here is the result. I'll investigate mako result. + ../python.default -m perf compare_to default.json patched.json -G --min-speed=1 Slower (20): - mako: 40.9 ms +- 0.4 ms -> 44.7 ms +- 0.6 ms: 1.09x slower (+9%) - chaos: 298 ms +- 3 ms -> 308 ms +- 2 ms: 1.03x

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread INADA Naoki
INADA Naoki added the comment: I'm running pyperformance. -- Added file: http://bugs.python.org/file46487/loadmethod-methoddescr.patch ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread STINNER Victor
STINNER Victor added the comment: > * Create unbound PyCFunction and cache it Does it mean create a new private type, similar to PyCFunction_Type (PyCFunctionObject) but without the self attribute? IMHO creating a new type is complex. I'm not sure that it's worth it, especially if the

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread STINNER Victor
STINNER Victor added the comment: INADA Naoki: "LOAD_METHOD support was based on tp_fastcall. (...) Other ideas to support LOAD_METHOD for C function are: * Add _PyMethodDescr_FastCallKeywords and call it in call_function." It seems like a very small subset of tp_fastcall. If it provides a

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread Yury Selivanov
Yury Selivanov added the comment: > * Add _PyMethodDescr_FastCallKeywords and call it in call_function. This option seems to be the easiest to implement. -- ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread INADA Naoki
INADA Naoki added the comment: LOAD_METHOD support was based on tp_fastcall. Without LOAD_METHOD support, methoddescr_get is called and stack layout after LOAD_METHOD is: NULL, (bound)PyCFunction, arg1, arg2, ... argN With LOAD_METHOD support, stack layout is: PyMethodDescrObject, self,

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-02-01 Thread STINNER Victor
STINNER Victor added the comment: INADA Naoki: "Maybe, we should do: * Make clinic use more METH_FASTCALL * Use clinic more in builtin methods; before trying this optimization." I created the issue #29286 "Use METH_FASTCALL in str methods" which is now fixed. I started to propose patches for

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-01-18 Thread Roundup Robot
Roundup Robot added the comment: New changeset 0b219348ec9e by Victor Stinner in branch 'default': Optimize methoddescr_call(): avoid temporary PyCFunction https://hg.python.org/cpython/rev/0b219348ec9e -- nosy: +python-dev ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-01-13 Thread INADA Naoki
INADA Naoki added the comment: Maybe, we should do * Make clinic use more METH_FASTCALL * Use clinic more in builtin methods before trying this optimization. -- ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-01-13 Thread INADA Naoki
INADA Naoki added the comment: This is proof of concept patch to support LOAD_METHOD & CALL_METHOD for METH_FASTCALL methods. (This patch should be applied after fastcall.patch) $ ./python -m perf timeit --compare-to `pwd`/python-fastcall -s "d = b''" -- "d.decode()" python-fastcall:

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-01-13 Thread STINNER Victor
Changes by STINNER Victor : -- dependencies: +Add tp_fastcall to PyTypeObject: support FASTCALL calling convention for all callable objects ___ Python tracker

[issue29263] Implement LOAD_METHOD/CALL_METHOD for C functions

2017-01-13 Thread STINNER Victor
New submission from STINNER Victor: The issue #29259 implements tp_fastcall on method_descriptor (PyMethodDescr_Type). According to http://bugs.python.org/issue26110#msg283093 it would allow to implement LOAD_METHOD and CALL_METHOD for C functions. -- messages: 285414 nosy: haypo,