#4912 NORM Never A: pygtk does thousands of futex(, FUTEX_WAKE) calls unnecessarily

Zarro Boogs per Child bugtracker at laptop.org
Wed Nov 14 08:33:08 EST 2007


#4912: pygtk does thousands of futex(,FUTEX_WAKE) calls unnecessarily
-------------------------+--------------------------------------------------
 Reporter:  gnu          |       Owner:  sj            
     Type:  enhancement  |      Status:  new           
 Priority:  normal       |   Milestone:  Never Assigned
Component:  library      |     Version:  Build 623     
 Keywords:  performance  |    Verified:  0             
-------------------------+--------------------------------------------------
 While debugging !SimCity's helper process, I noticed that it was doing a
 lot of system calls in between calls to poll().  It's calling futex(addr,
 FUTEX_WAKE, 1) and getting a result of 0.  This means it called into the
 kernel to wake up one process who was waiting on a shared semaphore, but
 no process was waiting.

 Futexes are supposed to run entirely in user space, using atomic
 instructions, unless and until they detect that the semaphore is being
 waited on by some other process that shares the same memory.  In that
 case, there's this system call (which allows both waiting, and waking).
 There's a bug, and the system call is being invoked frequently in
 circumstances where it's not needed.

 In !SimCity, the helper process which basically has nothing to do unless
 it gets a message from dbus, makes 6 futex() calls every time its poll()
 call returns (currently 10x/second).

 Since Sugar is written in Python and uses GTK, it suffers from these
 excessive system calls.

 Brief investigation showed that these calls are coming from a call to
 sem_post in Python's thread_pthread.c in !PyThread_release_lock.

-- 
Ticket URL: <http://dev.laptop.org/ticket/4912>
One Laptop Per Child <http://dev.laptop.org>
OLPC bug tracking system



More information about the Bugs mailing list