Ticket #4912 (new enhancement)

Opened 6 years ago

Last modified 6 years ago

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
Action Needed: Verified: no
Deployments affected: Blocked By:
Blocking:

Description

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

Changed 6 years ago by gnu

  • owner changed from sj to marco
  • component changed from library to sugar

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

Changed 6 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).

Changed 6 years ago by jg

  • milestone changed from Never Assigned to Future Release

Changed 6 years ago by fche

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