summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/runqueue.py
diff options
context:
space:
mode:
authorEtienne Cordonnier <ecordonnier@snap.com>2023-09-20 09:41:48 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2023-09-22 07:45:47 +0100
commit46386988349e9247640841202165a92a9bd1db3c (patch)
tree01848a61db8b1333f6b0b45c30b7d0302e65ee79 /bitbake/lib/bb/runqueue.py
parent2a581252eae2c506237fb22f1f39fc26849b6431 (diff)
downloadpoky-46386988349e9247640841202165a92a9bd1db3c.tar.gz
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 <ecordonnier@snap.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/runqueue.py')
-rw-r--r--bitbake/lib/bb/runqueue.py4
1 files changed, 2 insertions, 2 deletions
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():
3159 if pipeout: 3159 if pipeout:
3160 pipeout.close() 3160 pipeout.close()
3161 bb.utils.nonblockingfd(self.input) 3161 bb.utils.nonblockingfd(self.input)
3162 self.queue = b"" 3162 self.queue = bytearray()
3163 self.d = d 3163 self.d = d
3164 self.rq = rq 3164 self.rq = rq
3165 self.rqexec = rqexec 3165 self.rqexec = rqexec
@@ -3178,7 +3178,7 @@ class runQueuePipe():
3178 3178
3179 start = len(self.queue) 3179 start = len(self.queue)
3180 try: 3180 try:
3181 self.queue = self.queue + (self.input.read(102400) or b"") 3181 self.queue.extend(self.input.read(102400) or b"")
3182 except (OSError, IOError) as e: 3182 except (OSError, IOError) as e:
3183 if e.errno != errno.EAGAIN: 3183 if e.errno != errno.EAGAIN:
3184 raise 3184 raise