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.

classification
Title: expose pthread_getcpuclockid in time module
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 3.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, pdox, vstinner
Priority: normal Keywords:

Created on 2017-09-26 18:33 by pdox, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 3756 merged pdox, 2017-09-26 18:33
PR 3904 merged benjamin.peterson, 2017-10-06 05:09
Messages (6)
msg303059 - (view) Author: (pdox) * Date: 2017-09-26 18:33
time.clock_gettime() makes it possible to retrieve the thread-specific cpu-time clock for the current thread using time.CLOCK_THREAD_CPUTIME_ID. However, it is currently not possible in Python to retrieve the thread-specific clock for other threads. Exposing pthread_getcpuclockid() makes this possible.
msg303743 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2017-10-05 07:01
New changeset e14679c78464d1e0e16786c2a0e9bcebe49e842b by Benjamin Peterson (pdox) in branch 'master':
closes bpo-31596: Add an interface for pthread_getcpuclockid(3) (#3756)
https://github.com/python/cpython/commit/e14679c78464d1e0e16786c2a0e9bcebe49e842b
msg303769 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-05 13:57
The test is too strict, it fails on many buildbots.

Four examples:

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%2010.x%20Shared%203.x/builds/1008/steps/test/logs/stdio

======================================================================
FAIL: test_pthread_getcpuclockid (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Lib/test/test_time.py", line 100, in test_pthread_getcpuclockid
    self.assertLessEqual(t2, t3)
AssertionError: 16.309616 not less than or equal to 16.309358

http://buildbot.python.org/all/builders/s390x%20Debian%203.x/builds/1466/steps/test/logs/stdio

======================================================================
FAIL: test_pthread_getcpuclockid (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/dje/cpython-buildarea/3.x.edelsohn-debian-z/build/Lib/test/test_time.py", line 99, in test_pthread_getcpuclockid
    self.assertLessEqual(t1, t2)
AssertionError: 0.938456056 not less than or equal to 0.8324859600000001

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Non-Debug%203.x/builds/999/steps/test/logs/stdio

======================================================================
FAIL: test_pthread_getcpuclockid (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current.nondebug/build/Lib/test/test_time.py", line 100, in test_pthread_getcpuclockid
    self.assertLessEqual(t2, t3)
AssertionError: 0.813547 not less than or equal to 0.81335

http://buildbot.python.org/all/builders/AMD64%20FreeBSD%20CURRENT%20Debug%203.x/builds/996/steps/test/logs/stdio

======================================================================
FAIL: test_pthread_getcpuclockid (test.test_time.TimeTestCase)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/home/buildbot/python/3.x.koobs-freebsd-current/build/Lib/test/test_time.py", line 100, in test_pthread_getcpuclockid
    self.assertLessEqual(t2, t3)
AssertionError: 1.121773 not less than or equal to 1.121547
msg303781 - (view) Author: (pdox) * Date: 2017-10-05 19:01
This looks specific to FreeBSD and s390x. Those platforms might not provide the same cpu-time clock consistency guarantees as Linux+glibc+x86. Would it be ok to just disable the ordering check for those systems?
msg303800 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2017-10-06 05:50
New changeset 86566702f311f8e90600e85350f6b6769a384ea5 by Benjamin Peterson in branch 'master':
weaken pthread_getcpuclockid test (more bpo-31596) (#3904)
https://github.com/python/cpython/commit/86566702f311f8e90600e85350f6b6769a384ea5
msg303809 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2017-10-06 09:03
Thank you Benjamin, buildots are back to green :-)

I prefer the new unit test which only tests pthread_getcpuclockid() clock and not make any assumption on the link between this clock and CLOCK_THREAD_CPUTIME_ID.
History
Date User Action Args
2022-04-11 14:58:52adminsetgithub: 75777
2017-10-06 09:03:39vstinnersetmessages: + msg303809
2017-10-06 05:50:44benjamin.petersonsetmessages: + msg303800
2017-10-06 05:09:37benjamin.petersonsetpull_requests: + pull_request3875
2017-10-05 19:01:44pdoxsetmessages: + msg303781
2017-10-05 13:57:02vstinnersetnosy: + vstinner
messages: + msg303769
2017-10-05 07:01:58benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg303743

resolution: fixed
stage: resolved
2017-09-26 18:33:14pdoxcreate