Skip to content
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

[SR-12124] [NumberDate] CFGetSystemUptime for BSD and Windows #3273

Open
benrimmington opened this issue Feb 4, 2020 · 5 comments
Open

[SR-12124] [NumberDate] CFGetSystemUptime for BSD and Windows #3273

benrimmington opened this issue Feb 4, 2020 · 5 comments

Comments

@benrimmington
Copy link
Contributor

@benrimmington benrimmington commented Feb 4, 2020

Previous ID SR-12124
Radar rdar://problem/59216628
Original Reporter @benrimmington
Type Improvement
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Improvement
Assignee None
Priority Medium

md5: 69fb038c8490173be7492fcf9739e539

Issue Description:

Re: CFGetSystemUptime — use CLOCK_UPTIME for BSD, and QueryUnbiasedInterruptTimePrecise for Windows?

CLOCK_MONOTONIC is the correct choice for Linux and Cygwin, because it excludes system "downtime" on those platforms.

CLOCK_UPTIME is available on FreeBSD and OpenBSD, so it might be a better option for TARGET_OS_BSD.

GetTickCount64 may include system "downtime", and the result is in milliseconds, which might not be precise enough. For example, ProcessInfo.processInfo.systemUptime is currently used by swift-corelibs-xctest.

QueryUnbiasedInterruptTimePrecise excludes system "downtime", and the result is in 100-nanosecond units. It is also used by Cygwin and Dispatch for the same purpose.

@benrimmington
Copy link
Contributor Author

@benrimmington benrimmington commented Feb 4, 2020

Cc: @compnerd

@beccadax
Copy link
Contributor

@beccadax beccadax commented Feb 6, 2020

@swift-ci create

@benrimmington
Copy link
Contributor Author

@benrimmington benrimmington commented May 18, 2020

Cc: 3405691582 (JIRA User)

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented May 18, 2020

Comment by 3405691582 (JIRA)

👍

@swift-ci
Copy link
Contributor

@swift-ci swift-ci commented Mar 8, 2021

Comment by 3405691582 (JIRA)

Just something to think about since I brushed up against this recently: on OpenBSD at least, CLOCK_MONOTONIC and CLOCK_UPTIME are reasonably close, but a lot of Foundation uses MONOTONIC which Dispatch may interpret as UPTIME since it is trying to do stuff like clock inference (c.f. https://github.com/apple/swift-corelibs-libdispatch/blob/f13ea5dcc055e5d2d7c02e90d8c9907ca9dc72e1/src/shims/time.h#L257). I don't have any solutions or ideas for this right now, but it's something interesting to think about.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants