From 9043034da53658ab2db67da28699e8a01bfe5206 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Wed, 4 Jan 2023 17:47:44 +0000 Subject: bitbake: cooker: Rework the parsing results submission 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. (Bitbake rev: 9ece4a2e406509bd89dbce8dac80a02e600b0ecf) Signed-off-by: Richard Purdie --- bitbake/lib/bb/cooker.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'bitbake/lib/bb/cooker.py') diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 738849d189..1d347ddc52 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/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() -- cgit v1.2.3-54-g00ecf