Skip to content

bpo-41710: gc_collect_main() uses _PyTime_GetPerfCounter() #28676

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 1, 2021
Merged

bpo-41710: gc_collect_main() uses _PyTime_GetPerfCounter() #28676

merged 1 commit into from
Oct 1, 2021

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Oct 1, 2021

If the DEBUG_STATS debug flag is set, gc_collect_main() now uses
_PyTime_GetPerfCounter() instead of _PyTime_GetMonotonicClock() to
measure the elapsed time.

On Windows, _PyTime_GetMonotonicClock() only has a resolution of 15.6
ms, whereas _PyTime_GetPerfCounter() is closer to a resolution of 100
ns.

https://bugs.python.org/issue41710

If the DEBUG_STATS debug flag is set, gc_collect_main() now uses
_PyTime_GetPerfCounter() instead of _PyTime_GetMonotonicClock() to
measure the elapsed time.

On Windows, _PyTime_GetMonotonicClock() only has a resolution of 15.6
ms, whereas _PyTime_GetPerfCounter() is closer to a resolution of 100
ns.
@vstinner
Copy link
Member Author

vstinner commented Oct 1, 2021

Code history:

  • First, it called time.time() and converted the result as C double
  • Then, it called _PyTime_gettimeofday() which uses _PyTime_timeval type
  • Then, it called _PyTime_monotonic() which uses _PyTime_timeval type
  • Then, ti called _PyTime_GetMonotonicClock() which uses _PyTime_t type

@vstinner vstinner merged commit 54957f1 into python:main Oct 1, 2021
@vstinner vstinner deleted the gc_collect_perf_counter branch October 1, 2021 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants