You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actually, this is a performance bug. Not a feature/enhancement. clock_gettime_ns() does not use floating point operations and should be faster than old gettimeofday(). Unfotunately in Python it's not so. Checked in Linux X86_64 kernel 6.5.7, CPython 3.11.6
@pochmann too slow comparing to time.time() = gettimeofday(). For example, CLOCK_REALTIME_COARSE by definition should be faster (but coarse). In fact, it's not faster in Python. I did a glimpse on the implementation. For reasons that I don't understand, there are many useless wrappers around simple things.
I reopen the issue: I wrote PR #111641 which makes clock_gettime() and clock_gettime_ns() up to 2x faster by using a faster calling convention (METH_VARARGS => METH_O).
I dislike backporting optimizations. Better performance is not worth it compared to the risk of regression. I close the issue. Thanks @socketpair for the bug report.
Activity
[-]time.clock_gettime_ns is too slow[/-][+]time.clock_gettime_ns() is too slow[/+]pochmann commentedon Oct 30, 2023
"too slow" for what?
socketpair commentedon Oct 30, 2023
@pochmann too slow comparing to time.time() = gettimeofday(). For example, CLOCK_REALTIME_COARSE by definition should be faster (but coarse). In fact, it's not faster in Python. I did a glimpse on the implementation. For reasons that I don't understand, there are many useless wrappers around simple things.
Why not to do this:
I beat, it will be faster than current implementation, although I did not check yet.
vstinner commentedon Nov 1, 2023
I'm not sure what this issue is about. If you want to propose a change, go ahead.
socketpair commentedon Nov 2, 2023
I have checked, my optimizations give nothing, so closing the issue :(
pythongh-111482: Use Argument Clinic for clock_gettime()
pythongh-111482: Use Argument Clinic for clock_gettime()
pythongh-111482: Use Argument Clinic for clock_gettime()
vstinner commentedon Nov 2, 2023
I reopen the issue: I wrote PR #111641 which makes clock_gettime() and clock_gettime_ns() up to 2x faster by using a faster calling convention (METH_VARARGS => METH_O).
gh-111482: Use Argument Clinic for clock_gettime() (#111641)
pythongh-111482: Use Argument Clinic for clock_gettime() (python#111641)
hugovk commentedon Nov 9, 2023
#111641 was merged. Does it need backporting? If not, let's close this issue.
vstinner commentedon Nov 9, 2023
I dislike backporting optimizations. Better performance is not worth it compared to the risk of regression. I close the issue. Thanks @socketpair for the bug report.
pythongh-111482: Fix time_clockid_converter() on AIX
gh-111482: Fix time_clockid_converter() on AIX (#112170)
pythongh-111482: Use Argument Clinic for clock_gettime() (python#111641)
pythongh-111482: Fix time_clockid_converter() on AIX (python#112170)
pythongh-111482: Use Argument Clinic for clock_gettime() (python#111641)
pythongh-111482: Fix time_clockid_converter() on AIX (python#112170)