aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorEtienne Cordonnier <ecordonnier@snap.com>2023-09-22 10:51:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-10-15 13:40:14 +0100
commit9993a89e5b97dda5f3657e5a7cc3a4fa94ff7111 (patch)
treeb06fc3c4314e8d9f7537c5b517c5194bf9d1b66c /lib
parentd677daa0770c66010fc4ed0af5bbbb94752ba590 (diff)
downloadbitbake-contrib-9993a89e5b97dda5f3657e5a7cc3a4fa94ff7111.tar.gz
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. Signed-off-by: Etienne Cordonnier <ecordonnier@snap.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> Signed-off-by: Steve Sakoman <steve@sakoman.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/bb/runqueue.py4
1 files changed, 2 insertions, 2 deletions
diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py
index 569520707..46ff30a7d 100644
--- a/lib/bb/runqueue.py
+++ b/lib/bb/runqueue.py
@@ -3101,7 +3101,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
@@ -3120,7 +3120,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