All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] cooker: Rework the parsing results submission
@ 2023-01-05 11:51 Richard Purdie
  2023-01-05 11:51 ` [PATCH 2/2] cooker: Clean up inotify idle handler Richard Purdie
  0 siblings, 1 reply; 2+ messages in thread
From: Richard Purdie @ 2023-01-05 11:51 UTC (permalink / raw)
  To: bitbake-devel

The loop submitting the parser results was not efficient on many core systems
as may of the parsers could block for a long time waiting to send the results.
While a result was pending, the code wouldn't parse further jobs.

Change the code to parse further jobs even if the results can't be submitted
and lower the result submission timeout to keep the parsers busy.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cooker.py | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 738849d189..1d347ddc52 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -2107,25 +2107,29 @@ class Parser(multiprocessing.Process):
         multiprocessing.util.Finalize(None, bb.fetch.fetcher_parse_save, exitpriority=1)
 
         pending = []
+        havejobs = True
         try:
-            while True:
+            while havejobs or pending:
                 if self.quit.is_set():
                     break
 
-                if pending:
-                    result = pending.pop()
-                else:
-                    try:
-                        job = self.jobs.pop()
-                    except IndexError:
-                        break
+                job = None
+                try:
+                    job = self.jobs.pop()
+                except IndexError:
+                    havejobs = False
+                if job:
                     result = self.parse(*job)
                     # Clear the siggen cache after parsing to control memory usage, its huge
                     bb.parse.siggen.postparsing_clean_cache()
-                try:
-                    self.results.put(result, timeout=0.25)
-                except queue.Full:
                     pending.append(result)
+
+                if pending:
+                    try:
+                        result = pending.pop()
+                        self.results.put(result, timeout=0.05)
+                    except queue.Full:
+                        pending.append(result)
         finally:
             self.results.close()
             self.results.join_thread()
-- 
2.37.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [PATCH 2/2] cooker: Clean up inotify idle handler
  2023-01-05 11:51 [PATCH 1/2] cooker: Rework the parsing results submission Richard Purdie
@ 2023-01-05 11:51 ` Richard Purdie
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Purdie @ 2023-01-05 11:51 UTC (permalink / raw)
  To: bitbake-devel

We no longer need to abstract the inotify callback handler, remove the
abstraction and simplify/clean up the code.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
 lib/bb/cooker.py         | 6 ------
 lib/bb/server/process.py | 5 +++--
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 1d347ddc52..d2c42c858d 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -190,12 +190,6 @@ class BBCooker:
 
         self.inotify_modified_files = []
 
-        def _process_inotify_updates(server, cooker, halt):
-            cooker.process_inotify_updates()
-            return 1.0
-
-        self.idleCallBackRegister(_process_inotify_updates, self)
-
         # TOSTOP must not be set or our children will hang when they output
         try:
             fd = sys.stdout.fileno()
diff --git a/lib/bb/server/process.py b/lib/bb/server/process.py
index 78fdc6cf71..4422fd7311 100644
--- a/lib/bb/server/process.py
+++ b/lib/bb/server/process.py
@@ -158,8 +158,7 @@ class ProcessServer():
     def wait_for_idle(self, timeout=30):
         # Wait for the idle loop to have cleared
         with self.idle_cond:
-            # FIXME - the 1 is the inotify processing in cooker which always runs
-            self.idle_cond.wait_for(lambda: len(self._idlefuns) <= 1, timeout)
+            self.idle_cond.wait_for(lambda: len(self._idlefuns) == 0, timeout)
 
     def main(self):
         self.cooker.pre_serve()
@@ -389,6 +388,8 @@ class ProcessServer():
             nextsleep = 0.1
             fds = []
 
+            self.cooker.process_inotify_updates()
+
             with bb.utils.lock_timeout(self._idlefuncsLock):
                 items = list(self._idlefuns.items())
 
-- 
2.37.2



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-01-05 11:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-05 11:51 [PATCH 1/2] cooker: Rework the parsing results submission Richard Purdie
2023-01-05 11:51 ` [PATCH 2/2] cooker: Clean up inotify idle handler Richard Purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.