Opened 9 years ago

Last modified 9 years ago

#4912 new enhancement

pygtk does thousands of futex(,FUTEX_WAKE) calls unnecessarily

Reported by: gnu Owned by: marco
Priority: normal Milestone: Future Release
Component: sugar Version: 1.0-software-build-623
Keywords: performance Cc: fche
Blocked By: Blocking:
Deployments affected: Action Needed:
Verified: no


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.

Change History (4)

comment:1 Changed 9 years ago by gnu

  • Component changed from library to sugar
  • Owner changed from sj to marco

oops - wrong "library". There's no Python component to report bugs against -- I'll give it to Marco :-)

comment:2 Changed 9 years ago by marco

Can you please report this upstream and add a reference to the report here? You are going to be much better than me at discussing this issue with the upstream developers.

Sugar is generally OK as component for stuff which affects the whole UI part of the system (Sugar shell + activities).

comment:3 Changed 9 years ago by jg

  • Milestone changed from Never Assigned to Future Release

comment:4 Changed 9 years ago by fche

  • Cc fche added
Note: See TracTickets for help on using tickets.