On Sat, Feb 28, 2015 at 02:21:22AM +0300, Alexander Monakov wrote: > Hello, > > As new cancellation has landed (except that __timedwait fails to propagate > ECANCELED in addition to ETIMEDOUT and EINTR), I'm happy to post semaphore > redesign. We discussed this implementation with Rich on IRC once, and > presently I'm not aware of any issues (finally!), but still testing and > performance comparison need to be done. Thanks! I'm attaching a performance testing program I used in the past. Its time measurement is not very precise, but it should show large-scale differences. It measures the number of messages that can be send back and forth between two threads in 2 seconds by cancelling the two threads after sleep(2). Some other things we should test for performance: - Do something like the attached but with multiple threads contending on semaphores rather than uncontended message passing. - Time/cycles per call for sem_post and sem_trywait and uncontended sem_wait -- this looks like it should be an obvious win though. - Perhaps something to hammer posts and trywait -- it's not clear that this would model any real-world behavior, but it could show something interesting anyway. I doubt we'll see any measurable differences in usage cases where the futex syscall is expected; it should dominate there. Rich