From 46386988349e9247640841202165a92a9bd1db3c Mon Sep 17 00:00:00 2001 From: Etienne Cordonnier Date: Wed, 20 Sep 2023 09:41:48 +0200 Subject: bitbake: bitbake-worker/runqueue: Avoid unnecessary bytes object copies declaring queue=b"" creates an object of types bytes(). bytes() is an immutable object, and therefore doing "self.queue = self.queue + r" creates a new object containing "self.queue" concatenated with "r". On my test setup, we are passing 180MB of data of "workerdata" to the bitbake-worker, so those copies significantly slow down the initialization of the bitbake-worker. Rather use bytearray() which a mutable type, and use extend() to avoid copies. In my test setup, byterray.extend() is 10.000 times faster than copying the queue, for a queue size of 180MB. (Bitbake rev: 2302b5316091dff189e6c3f546341b2274ed9d0a) Signed-off-by: Etienne Cordonnier Signed-off-by: Richard Purdie --- bitbake/lib/bb/runqueue.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index c88d7129ca..c40a3be212 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py @@ -3159,7 +3159,7 @@ class runQueuePipe(): if pipeout: pipeout.close() bb.utils.nonblockingfd(self.input) - self.queue = b"" + self.queue = bytearray() self.d = d self.rq = rq self.rqexec = rqexec @@ -3178,7 +3178,7 @@ class runQueuePipe(): start = len(self.queue) try: - self.queue = self.queue + (self.input.read(102400) or b"") + self.queue.extend(self.input.read(102400) or b"") except (OSError, IOError) as e: if e.errno != errno.EAGAIN: raise -- cgit v1.2.3-54-g00ecf