Semaphored tasks not scheduling efficiently
Semaphored tasks not scheduling efficiently
- Subject: Semaphored tasks not scheduling efficiently
- From: Russ <email@hidden>
- Date: Tue, 27 May 2008 15:26:09 -0700 (PDT)
I am optimizing a multithreaded app using shark on an 8-core machine. There is a typical MPCreateSemaphore/MPSignalSemaphore semaphore-based setup that hands out work units to be processed to a set of worker threads, and it is is working... but when you look carefully with Shark you see that a fair portion of the time, only 7 cores are busy. As the work units are being released, the cores start up --- but under close examination sometimes one will start only for 2 usec or less, then stop with semaphore_timedwait_trap. It then goes away for a long time (multiples of the 10msec os thread slice) and the mach kernel shows that there is an idle thread running. Sometimes the 'hole" in utilization moves to a different core. It winds up biting twice because not only do you lose a core, but you wind up with a ragged inefficient finish that wastes 6 or 7 cores. All this repeats, giving me a swiss-cheese look in what should logically be a very dense shark system
trace. All the work eventually gets done and it works, but not as well as it should.
I saw some notes on some mach semaphores that don't make the target task immediately runnable, not sure if that's what's happening here, but once the main thread goes to sleep after starting the workers, the eighth runnable worker thread should surely start, I'd think.
Can anyone give insight into the MP semaphore and scheduling internals? Thanks.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden