Skip to contentSkip to conversation

cooker/server: Fix up 100% CPU usage at idle

PATCH Richard Purdie 1 participant 1 message Mar 10, 2015

lore
Share & tools
lore
#0 lore raw

The recent inotify changes are causing a 100% cpu usage issue in the idle handlers. To avoid this, we update the idle functions to optionally report a float value which is the delay before the function needs to be called again. 1 second is fine for the inotify handler, in reality its more like 0.1s due to the default idle function sleep.

This reverts performance regressions of 1.5 minutes on a kernel build and ~4-5 minutes on a image from scratch.

bitbake/lib/bb/cooker.py +1 -1
index 47dc8a3..68aa532 100644
@@ -142,7 +142,7 @@ class BBCooker:
                     # read notified events and enqeue them
                     n.read_events()
                     n.process_events()
-            return True
+            return 1.0
 
         self.configuration.server_register_idlecallback(_process_inotify_updates, [self.confignotifier, self.notifier])
 
bitbake/lib/bb/server/process.py +3 -0
index 7671b26..c9286dd 100644
@@ -135,6 +135,9 @@ class ProcessServer(Process, BaseImplServer):
                     nextsleep = None
                 elif retval is True:
                     nextsleep = None
+                elif isinstance(retval, float):
+                    if (retval < nextsleep):
+                        nextsleep = retval
                 elif nextsleep is None:
                     continue
                 else:
bitbake/lib/bb/server/xmlrpc.py +3 -0
index 17f3d9d..75ec855 100644
@@ -242,6 +242,9 @@ class XMLRPCServer(SimpleXMLRPCServer, BaseImplServer):
                         del self._idlefuns[function]
                     elif retval is True:
                         nextsleep = 0
+                    elif isinstance(retval, float):
+                        if (retval < nextsleep):
+                            nextsleep = retval
                     else:
                         fds = fds + retval
                 except SystemExit: