[ros-users] need help: set_parameters service callback very sluggish with nodelet-based camera1394 driver

Jack O'Quin jack.oquin at gmail.com
Thu Feb 3 18:51:12 UTC 2011


On Thu, Feb 3, 2011 at 11:42 AM, Blaise Gassend <blaise at willowgarage.com> wrote:
>> It's the most elegant solution, but not cheap.
>>
>> On an SMP machine, suspending the current thread and checking all the
>> run queues in case there is something waiting on this lock is an
>> expensive operation. That's probably why Linux does not do it
>> automatically when the lock is released.
>
> In this case you would be calling it once per frame. I would not worry
> about the cost of that yield once per frame, or on the order of 100
> times per second. To put things into perspective, there are probably
> many context switches happening to gather the frame.
>
> Putting it in automatically when the lock is released could cause
> millions of yields per second depending on how locks are being used.
> That would be a much greater cause for concern.

Yes, that's all true.

I was not really arguing that it would be too expensive to add the
yield(), mainly just rationalizing why I don't want to change it. If
you don't have a really good reason for doing something, it's best to
have at least three bad ones. :-)

If I'd thought of using yield() in the first place, I would have done
it that way.
-- 
 joq



More information about the ros-users mailing list