[CDRIVER-4526] bson_get_monotonic_time has 10-16 millisecond resolution on Windows Created: 16/Nov/22  Updated: 21/Nov/22

Status: Backlog
Project: C Driver
Component/s: APM
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: Jeremy Mikola Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to PHPC-2143 Add Windows builds to GitHub Actions ... Closed

 Description   

Summary

bson_get_monotonic_time() uses GetTickCount64 on Windows, which appears to have a resolution in the range of 10-16 milliseconds. This is actually quite a bit worse than what I originally assumed reading the libbson code, which implies that the returned value is just milliseconds.

This came up while fixing some command monitoring tests on Windows for PHPC-2143. We had a few tests that assert a non-zero duration for a commandFailed or commandSucceeded event, and I noticed that these tests occasionally fail (presumably when the calculated duration is less than GetTickCount64's resolution.

Given this limitation, is there an alternative that would make more sense on Windows? Is command monitoring the only likely case where diffing two bson_get_monotonic_time() return values might evaluate to zero? If not, perhaps bson_gettimeofday would make a better fallback.

Environment

  • libmongoc 1.23.1
  • Windows Server 2019 64-bit
  • MSVC15 (Visual C++ 2017) x64

How to Reproduce

Example script: commandSucceededEvent-001.phpt


Generated at Wed Feb 07 21:21:11 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.