diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-20 10:37:04 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-21 12:16:28 +0000 |
commit | f95a645dd4fbb98afe6f10cd28d5908bbe845fbc (patch) | |
tree | ecf3a5a09c272de5bce44efb28622ac00d2c3f79 | |
parent | b97de63d2feaeb7710b7550dfc4144f41f5c8fc6 (diff) | |
download | poky-f95a645dd4fbb98afe6f10cd28d5908bbe845fbc.tar.gz |
bitbake: bitbake-worker/cooker: Increase default pipe size
The default pipe size is 64kb on builds, which can be inefficient
for larger log files from workers. Increase the pipe size to 512kb
since build systems have decent amounts of memory and this is a more
efficient way of batching the data.
Tweak the default read sizes to match the pipe size for efficiency.
Since the contstant is only present in python 3.10 onwards, add
some compatibility code.
(Bitbake rev: 69c14e46600ba5ae9703f67704ab2548875ae6d7)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rwxr-xr-x | bitbake/bin/bitbake-worker | 14 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 2 |
2 files changed, 13 insertions, 3 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index a8a9660c5f..88217182fb 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
@@ -21,9 +21,14 @@ import traceback | |||
21 | import queue | 21 | import queue |
22 | import shlex | 22 | import shlex |
23 | import subprocess | 23 | import subprocess |
24 | import fcntl | ||
24 | from multiprocessing import Lock | 25 | from multiprocessing import Lock |
25 | from threading import Thread | 26 | from threading import Thread |
26 | 27 | ||
28 | # Remove when we have a minimum of python 3.10 | ||
29 | if not hasattr(fcntl, 'F_SETPIPE_SZ'): | ||
30 | fcntl.F_SETPIPE_SZ = 1031 | ||
31 | |||
27 | bb.utils.check_system_locale() | 32 | bb.utils.check_system_locale() |
28 | 33 | ||
29 | # Users shouldn't be running this code directly | 34 | # Users shouldn't be running this code directly |
@@ -44,7 +49,6 @@ if sys.argv[1].startswith("decafbadbad"): | |||
44 | # updates to log files for use with tail | 49 | # updates to log files for use with tail |
45 | try: | 50 | try: |
46 | if sys.stdout.name == '<stdout>': | 51 | if sys.stdout.name == '<stdout>': |
47 | import fcntl | ||
48 | fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) | 52 | fl = fcntl.fcntl(sys.stdout.fileno(), fcntl.F_GETFL) |
49 | fl |= os.O_SYNC | 53 | fl |= os.O_SYNC |
50 | fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl) | 54 | fcntl.fcntl(sys.stdout.fileno(), fcntl.F_SETFL, fl) |
@@ -56,6 +60,12 @@ logger = logging.getLogger("BitBake") | |||
56 | 60 | ||
57 | worker_pipe = sys.stdout.fileno() | 61 | worker_pipe = sys.stdout.fileno() |
58 | bb.utils.nonblockingfd(worker_pipe) | 62 | bb.utils.nonblockingfd(worker_pipe) |
63 | # Try to make the pipe buffers larger as it is much more efficient. If we can't | ||
64 | # e.g. out of buffer space (/proc/sys/fs/pipe-user-pages-soft) then just pass over. | ||
65 | try: | ||
66 | fcntl.fcntl(worker_pipe, fcntl.F_SETPIPE_SZ, 512 * 1024) | ||
67 | except: | ||
68 | pass | ||
59 | # Need to guard against multiprocessing being used in child processes | 69 | # Need to guard against multiprocessing being used in child processes |
60 | # and multiple processes trying to write to the parent at the same time | 70 | # and multiple processes trying to write to the parent at the same time |
61 | worker_pipe_lock = None | 71 | worker_pipe_lock = None |
@@ -357,7 +367,7 @@ class runQueueWorkerPipe(): | |||
357 | def read(self): | 367 | def read(self): |
358 | start = len(self.queue) | 368 | start = len(self.queue) |
359 | try: | 369 | try: |
360 | self.queue.extend(self.input.read(102400) or b"") | 370 | self.queue.extend(self.input.read(512*1024) or b"") |
361 | except (OSError, IOError) as e: | 371 | except (OSError, IOError) as e: |
362 | if e.errno != errno.EAGAIN: | 372 | if e.errno != errno.EAGAIN: |
363 | raise | 373 | raise |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 1b5b58f352..61608ac603 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -3318,7 +3318,7 @@ class runQueuePipe(): | |||
3318 | 3318 | ||
3319 | start = len(self.queue) | 3319 | start = len(self.queue) |
3320 | try: | 3320 | try: |
3321 | self.queue.extend(self.input.read(102400) or b"") | 3321 | self.queue.extend(self.input.read(512 * 1024) or b"") |
3322 | except (OSError, IOError) as e: | 3322 | except (OSError, IOError) as e: |
3323 | if e.errno != errno.EAGAIN: | 3323 | if e.errno != errno.EAGAIN: |
3324 | raise | 3324 | raise |