[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-dev] Re: [Gnash-commit] gnash ChangeLog server/asobj/NetStream.cp
[Gnash-dev] Re: [Gnash-commit] gnash ChangeLog server/asobj/NetStream.cpp serv...
Wed, 16 May 2007 14:53:21 -0700
> + // 2) The buffer has be "starved" (not being filled as quickly as
> + // and we then wait until the buffer contains some data (1 sec)
This is the second gnash checkin I've seen in a couple of weeks that
involves 1-second polling when our code is waiting for some data. The
Linux community (and the OLPC community in particular) is trying to
fix all the code that does this kind of polling, because it wastes
time and energy. Instead, the code should wait until something
actually happens, and only wake up then, rather than once a second.
The OLPC is designed to be able to power down its CPU chip during any
period when the system is totally idle for about a second or more.
The kernel knows when processes/threads have asked to wake up, and
won't be able to suspend itself and save power, if various threads are
waking up once a second. Here's a Fedora bugzilla entry that shows
all the programs that are being fixed for this kind of behavior:
Instead of waking up periodically and polling: If it's waiting on a
file descriptor, then select() or poll() the file descriptor (with no
fixed timeout specified). If it's waiting for another thread, then it
should wait on a semaphore, or a file descriptor written by that
thread, and the other thread should trigger it only when there's
actual data to process. If there's really no way to avoid polling, do
exponential backoff, such that you wait a second, then if nothing
happened, wait two seconds, then four seconds, etc, so that when idle,
you rapidly ramp up to sleeping for minutes at a time.)
PS: I realize Tomas's particular checkin wasn't code that polls once a
second -- just comments that document the existing 1-second polling.
I'm not blaming anybody -- just encouraging all gnash developers to
make our threads sleep UNTIL there is something useful for them to do.
|[Prev in Thread]
||[Next in Thread]|
- [Gnash-dev] Re: [Gnash-commit] gnash ChangeLog server/asobj/NetStream.cpp serv...,
John Gilmore <=