Repository navigation
perf(platform): macOS reads the monotonic clock through mach_absolute_time - #114
Merged
Merged
Conversation
…_time GetTickCount64 and QueryPerformanceCounter called clock_gettime, 17 ns a read on Apple Silicon against 5 ns for mach_absolute_time, and the clock reads were 7.5% of Constantine's main thread. The kernel-call summary also reads the clock every 256 calls instead of every call. Constantine capped: 4.20 -> 3.92 ms of work a frame; uncapped unchanged.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On macOS,
GetTickCount64andQueryPerformanceCounternow readmach_absolute_timeinstead ofclock_gettime(CLOCK_MONOTONIC). On Apple Silicon that is 5 ns a read instead of 17 ns. Clock reads were 7.5% of Constantine's main thread.The kernel-call summary in
kernel_thunk_dispatchalso used to read the clock on every kernel call to see whether two seconds had passed. It now reads it once every 256 calls.Measurements
Apple M4, muted runs in the background. "Work per frame" is the "rest of frame" figure from the swap timing line.
TimeSplitters 2 stays at 60 capped on both builds. Uncapped it sits at exactly 120 fps on both, so neither run can show a difference.
Scope
#if defined(__APPLE__), and other POSIX hosts keepclock_gettime.