Kyle Moffett wrote:
> That is a *terrible* disgusting way to use yield. Better options:
> (1) inotify/dnotify
Sure, tie yourself to a Linux-specific mechanism that may or may not work
over things like NFS. That's much worse.
> (2) create a "foo.lock" file and put the mutex in that
Right, tie yourself to process-shared mutexes which historically weren't
available on Linux. That's much better than an option that's been stable for
a decade.
> (3) just start with the check-file-and-sleep loop.
How is that better? There is literally no improvement, since the first check
will (almost) always fail.
> > Now is this the best way to handle this situation? No. Does it
> > work better than just doing the wait loop from the start? Yes.
>
> It works better than doing the wait-loop from the start? What
> evidence do you provide to support this assertion?
The evidence is that more than half the time, this avoids the sleep. That
means it has zero cost, since the yield is no heavier than a sleep would be,
and has a possible benefit, since the first sleep may be too long.
> Specifically, in
> the first case you tell the kernel "I'm waiting for something but I
> don't know what it is or how long it will take"; while in the second
> case you tell the kernel "I'm waiting for something that will take
> exactly X milliseconds, even though I don't know what it is. If you
> really want something similar to the old behavior then just replace
> the "sched_yield()" call with a proper sleep for the estimated time
> it will take the program to create the file.
The problem is that if the estimate is too short, pre-emption will result in
a huge performance drop. If the estimate is too long, there will be some
wasted CPU. What was the claimed benefit of doing this again?
> > Is this a good way to use sched_yield()? Maybe, maybe not. But it
> > *is* an actual use of the API in a real app.
> We weren't looking for "actual uses", especially not in binary-only
> apps. What we are looking for is optimal uses of sched_yield(); ones
> where that is the best alternative. This... certainly isn't.
Your standards for "optimal" are totally unrealistic. In his case, it was
optimal. Using platform-specific optimizations would have meant more
development and test time for minimal benefit. Sleeping first would have had
some performance cost and no benefit. In his case, sched_yield was optimal.
Really.
DS
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[Index of Archives]
[Kernel Newbies]
[Netfilter]
[Bugtraq]
[Photo]
[Stuff]
[Gimp]
[Yosemite News]
[MIPS Linux]
[ARM Linux]
[Linux Security]
[Linux RAID]
[Video 4 Linux]
[Linux for the blind]
[Linux Resources]