Shark?

topic posted Sat, April 7, 2007 - 12:26 PM by 

Hello, all ...

I'm working on an internet application that runs on Windows and Mac OSX. It's written in C++ (the only real choice for cross-platform applcations that run natively), so 99% of the source is common across both platforms. However, i'm seeing some very different performance characteristics between them, so I fired up Shark to try to see where the OSX version is spending all of it's CPU.

After sampling "Time Period (All Thread States)", it tells me that 50% of the time my app is running, it's calling the BSD select() call. This makes sense -- we're always trying to talk to other nodes on the network, and we use select() to determine which other nodes are ready. The thing is, this same code runs on Windows, but while it uses 3% or so of the CPU on my Windows box, it uses 12% or more on my Mac (dual 2.3ghz G5). The Windows version also calls select() under the same circumstances (this is all common code to both platforms), and i've always considered select() not so great on Windows (as i'm sure MS would rather have us using MS-specific APIs like WaitForMultipleObjects()), so I was surprised to see what appears to be select() working much better on Windows than OSX.

So i'm wondering if i'm using Shark correctly. How am I actually supposed to use it? I point it at my process, select Time Period or Time Period (All Thread States), thinking that it will show me the percentage my code spends in any particular section, but ... well, I can't deliver a new kernel with the app, so optimizing select() is not an option, so i'm wondering ...

Regards,

John

Falling You - exploring the beauty of voice and sound
www.fallingyou.com
posted by:
  • Re: Shark?

    Sat, May 26, 2007 - 1:09 PM
    I don't think there's much you can do wrong with Shark and so far I found that its output was pretty accurate. Is there a way you can reduce the number of calls to select()?

Recent topics in "OS X Development"

Topic Author Replies Last Post
component kind Beau 1 January 20, 2008
grr -- having much difficulty building even the simplest plugi... 0 January 10, 2008
struct proc and sysctl(3) hoco 3 December 12, 2007
Xcode 3.0 0 November 28, 2007