Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-88494: Reduce CLOCK_RES to 1 ms in tests#118395

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Closed
vstinner wants to merge2 commits intopython:mainfromvstinner:clock_res

Conversation

vstinner
Copy link
Member

@vstinnervstinner commentedApr 29, 2024
edited by bedevere-appbot
Loading

On Windows, time.monotonic() now calls QueryPerformanceCounter() which has a resolution of 100 ns. Reduce CLOCK_RES from 50 or 100 ms to 1 ms.

On Windows, time.monotonic() now calls QueryPerformanceCounter()which has a resolution of 100 ns. Reduce CLOCK_RES from 50 or 100 msto 1 ms.
@vstinner
Copy link
MemberAuthor

Sadly, my change is too optimistic :-( test_asyncio failed on Windows:

FAIL: test_wait_for_handle (test.test_asyncio.test_windows_events.ProactorTests.test_wait_for_handle)----------------------------------------------------------------------Traceback (most recent call last):  File "D:\a\cpython\cpython\Lib\test\test_asyncio\test_windows_events.py", line 190, in test_wait_for_handle    self.assertGreaterEqual(elapsed, timeout - test_utils.CLOCK_RES)    ~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 0.4965299000000414 not greater than or equal to 0.499

loop._proactor.wait_for_handle() still has the bad 15.6 ms resolution :-(

Copy link
Member

@gvanrossumgvanrossum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Now I worry that other tests (that still use the 1ms value) will become flaky on Windows, unless you have a clear explanation why that fix is only needed in that one spot.

@vstinnervstinner added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 30, 2024
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@vstinner for commiteb4e7d3 🤖

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelApr 30, 2024
@vstinner
Copy link
MemberAuthor

Now I worry that other tests (that still use the 1ms value) will become flaky on Windows, unless you have a clear explanation why that fix is only needed in that one spot.

asyncio.BaseEventLoop.time() is time.monotonic(). On Windows, this clock now has a resolution of 100 ns, since I modified it to use QueryPerformanceCounter().

FAIL: test_wait_for_handle (test.test_asyncio.test_windows_events.ProactorTests.test_wait_for_handle)

This test calls RegisterWaitForSingleObject() which has a resolution of 15.6 ms.

I scheduled buildbot jobs to see how the change goes on more various machines.

@vstinner
Copy link
MemberAuthor

Failure on AMD64 Windows Server 2022 NoGIL PR:

FAIL: test_wait_timeout (test.test_multiprocessing_spawn.test_misc.TestWait.test_wait_timeout)----------------------------------------------------------------------Traceback (most recent call last):  File "C:\Users\Administrator\buildarea\pull_request.itamaro-win64-srv-22-aws.x64.nogil\build\Lib\test\_test_multiprocessing.py", line 5145, in test_wait_timeout    self.assertGreater(delta, timeout - CLOCK_RES)    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^AssertionError: 4.996562599902973 not greater than 4.999

@gvanrossum
Copy link
Member

Maybe the problem is that the meaning of the variable CLOCK_RES is ambiguous? Itlooks like it gives the actual clock resolution, but itactually seems to mean the tolerance for longer (or shorter) delays. Tests depending on close-to-exact delays will always be flaky -- or if we make the tolerance too large, they will be meaningless.

@vstinner
Copy link
MemberAuthor

While it's appealing to make the test stricter, CLOCK_RES is used to compare time.monotonic() values (resolution better than 1 us), but also to compare Windows "wait" functions (resolution of 15.6 ms). I prefer to abandon this PR. I don't want to have multiple CLOCK_RES depending on the function and/or the operating system. Let's keep the status quo of 50-100 ms tolerance.

@vstinnervstinner deleted the clock_res branchApril 30, 2024 15:12
@gvanrossum
Copy link
Member

Good call. Sorry it didn't work out, but they can't all be winners... :-)

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@gvanrossumgvanrossumgvanrossum approved these changes

@gpsheadgpsheadAwaiting requested review from gpsheadgpshead is a code owner

@1st11st1Awaiting requested review from 1st11st1 is a code owner

@asvetlovasvetlovAwaiting requested review from asvetlovasvetlov is a code owner

@kumaraditya303kumaraditya303Awaiting requested review from kumaraditya303kumaraditya303 is a code owner

@willingcwillingcAwaiting requested review from willingcwillingc is a code owner

Assignees
No one assigned
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@vstinner@bedevere-bot@gvanrossum

[8]ページ先頭

©2009-2025 Movatter.jp