1 2 3 4 5 6 7 8 9 10 | 33.373106ms/frame 33.752043ms/frame 33.407167ms/frame 33.768781ms/frame 33.811562ms/frame 33.737440ms/frame 33.974245ms/frame 34.046318ms/frame 33.900373ms/frame 33.344060ms/frame |
vbo
@Flyingsand, so I've just tried a CPU-melting way for the first time for some reason =) And I am getting quite strong 33.33ms. I can't get strong 16.6ms no matter what I am doing - I am getting peaks of 27-30ms peaks from time to time.
So I want to investigate all of this a bit more. Could you please share your brief experiment with thread priority setting so I can play with it a bit more? Or could you please just explain a bit how to get started with all of this scheduler configuration stuff.
1 2 3 4 5 6 7 8 9 10 | thread_precedence_policy_data_t policyData; policyData.importance = 8; kern_return_t result = thread_policy_set(mach_thread_self(), THREAD_PRECEDENCE_POLICY, (thread_policy_t)&policyData, THREAD_PRECEDENCE_POLICY_COUNT); if (result != KERN_SUCCESS) { // Error... } |
Cool. What CPU-melting way do you speak of?
1 2 3 4 5 6 7 8 9 10 | 0.016667s/frame 0.016667s/frame 0.016667s/frame 0.016667s/frame 0.016894s/frame 0.016667s/frame 0.016667s/frame 0.016774s/frame 0.016667s/frame 0.016667s/frame |
vboCool. What CPU-melting way do you speak of?
I was speaking about closed loop after OpenGL buffer flush with no sleeping at all. So called busy waiting.
Anyway after some work I've achieved (at least on my machine, day 32 game sources) quite strong 60 FPS timing even without CPU-melting. Looks like there was just a bug somewhere in my previous implementation and we don't actually need to tweak scheduler priorities!
It looks like this:
1 2 3 4 5 6 7 8 9 10 0.016667s/frame 0.016667s/frame 0.016667s/frame 0.016667s/frame 0.016894s/frame 0.016667s/frame 0.016667s/frame 0.016774s/frame 0.016667s/frame 0.016667s/frame
Actually mach_wait_until() precision without any tweaking is like 500-750 microseconds and Apple officially suggests us to treat worse precision as a hardware bug (https://developer.apple.com/library/ios/technotes/tn2169/_index.html). I don't know if we can believe it or not though. Better to test all of this on some older Mac.