linux-os (Dick Johnson) wrote:We actually experimented with usleep(0) and select(...) with a zeroed timeval. Both of these approaches performed worse than just using sched_yield(), depending on the system and some other conditions. Dual-core AMD64 vs single-CPU had quite different behaviors. Also, if the slapd main event loop was using epoll() instead of select(), the select's used for yields slowed down by a couple orders of magnitude. (A test that normally took ~30 seconds took as long as 45 minutes in one case, it was quite erratic.)
To fix the current problem, you can substitute usleep(0); It willIsn't that dangerous? Someday, someone working on linux (or some
give the CPU to somebody if it's computable, then give it back to
you. It seems to work in every case that sched_yield() has
mucked up (perhaps 20 to 30 here).
other unixish os) might come up with an usleep implementation where
usleep(0) just returns and becomes a no-op. Which probably is ok
with the usleep spec - it did sleep for zero time . . .