mrRay / vvopensource

OSC and MIDI frameworks for OS X and iOS, a framework for managing and rendering to GL textures in OS X, and a functional ISF (interactive shader format) implementation for OS X.
231 stars 33 forks source link

Excessive wakeups when using OSCInPort #19

Open markwheeler opened 8 years ago

markwheeler commented 8 years ago

I'm using a single OSCInPort to receive OSC messages and I noticed that it's responsible for a lot of thread sleeping / waking.

With the default interval of 0.01secs I'm seeing around 170 wake-ups per second in Activity Monitor. Extending the interval does of course reduce the wake-ups but it still seems like a lot.

Having a lot of wake-ups causes a warning in the Console along the lines of 'process Xxxxx[yyyy] caught causing excessive wakeups.' 'Maximum permitted wakeups rate (per sec): 150'.

As far as I can tell this message is just a warning (doesn't seem to have any effect) and it usually triggers when the wakeups count actually goes quite a lot higher than 150, but still it got me thinking maybe this was something worth optimising.

What do you think, is this something that could be done a different way while still being responsive to incoming messages?

For reference, there's some good info on this page about monitoring wakeups etc: https://developer.apple.com/library/mac/documentation/Performance/Conceptual/power_efficiency_guidelines_osx/Timers.html

mrRay commented 8 years ago

hi mark-

sorry for the delay!

i'm all for making stuff faster/more efficient, but it's not clear to me that this sort of modification would be a net win when all things are considered. if you think i overlooked something, or you have any other suggestions, ideas, or things you think i should try, i'd love to hear them!

markwheeler commented 8 years ago

Big thanks for looking into this in such depth!

It all totally makes sense, I must admit I hadn't really thought about super-high numbers of OSC messages – I mostly use VVOSC to receive user input from buttons so the number of input messages I get in my app is really low.

I guess you could have the option to use either 'mode' when initialising a port but I can see that could be quite a bit of effort to implement and may well complicate the code more than is worthwhile.

Really appreciate you taking the time to test this out and report back though :)