diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-27 14:55:50 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-08-28 15:12:45 +0100 |
commit | 34226b82daaaefb2bc2defbe586f26413201bb26 (patch) | |
tree | be24936976f88a6c224594b3322e021694462a5c /bitbake/bin | |
parent | ac66e15f5cf0dfabab84967338909632559f5b7b (diff) | |
download | poky-34226b82daaaefb2bc2defbe586f26413201bb26.tar.gz |
bitbake: bitbake-worker: Extra profiling data dump
Currently we get no profiling oversight into either the main bitbake worker
process, or the overall parsing before task execution. This adds in extra
profiling hooks so we can truly capture all parts of bitbake's execution
into the profile data.
To do this we modify the 'magic' value passed to bitbake-worker to trigger
the profiling, before the configuration data is sent over to the worker.
(Bitbake rev: 446e490bf485b712e5cee733dab5805254cdcad0)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake-worker | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/bitbake/bin/bitbake-worker b/bitbake/bin/bitbake-worker index d1ff5b36c5..c7992f7e82 100755 --- a/bitbake/bin/bitbake-worker +++ b/bitbake/bin/bitbake-worker | |||
@@ -12,10 +12,18 @@ import errno | |||
12 | import signal | 12 | import signal |
13 | 13 | ||
14 | # Users shouldn't be running this code directly | 14 | # Users shouldn't be running this code directly |
15 | if len(sys.argv) != 2 or sys.argv[1] != "decafbad": | 15 | if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): |
16 | print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") | 16 | print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") |
17 | sys.exit(1) | 17 | sys.exit(1) |
18 | 18 | ||
19 | profiling = False | ||
20 | if sys.argv[1] == "decafbadbad": | ||
21 | profiling = True | ||
22 | try: | ||
23 | import cProfile as profile | ||
24 | except: | ||
25 | import profile | ||
26 | |||
19 | logger = logging.getLogger("BitBake") | 27 | logger = logging.getLogger("BitBake") |
20 | 28 | ||
21 | try: | 29 | try: |
@@ -134,6 +142,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat | |||
134 | bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) | 142 | bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) |
135 | 143 | ||
136 | if pid == 0: | 144 | if pid == 0: |
145 | def child(): | ||
137 | global worker_pipe | 146 | global worker_pipe |
138 | pipein.close() | 147 | pipein.close() |
139 | 148 | ||
@@ -185,10 +194,20 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat | |||
185 | os._exit(1) | 194 | os._exit(1) |
186 | try: | 195 | try: |
187 | if not cfg.dry_run: | 196 | if not cfg.dry_run: |
188 | ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) | 197 | return bb.build.exec_task(fn, taskname, the_data, cfg.profile) |
189 | os._exit(ret) | ||
190 | except: | 198 | except: |
191 | os._exit(1) | 199 | os._exit(1) |
200 | if not profiling: | ||
201 | os._exit(child()) | ||
202 | else: | ||
203 | profname = "profile-%s.log" % (fn.replace("/", "-") + "-" + taskname) | ||
204 | prof = profile.Profile() | ||
205 | try: | ||
206 | ret = profile.Profile.runcall(prof, child) | ||
207 | finally: | ||
208 | prof.dump_stats(profname) | ||
209 | bb.utils.process_profilelog(profname) | ||
210 | os._exit(ret) | ||
192 | else: | 211 | else: |
193 | for key, value in envbackup.iteritems(): | 212 | for key, value in envbackup.iteritems(): |
194 | if value is None: | 213 | if value is None: |
@@ -363,7 +382,16 @@ class BitbakeWorker(object): | |||
363 | 382 | ||
364 | try: | 383 | try: |
365 | worker = BitbakeWorker(sys.stdin) | 384 | worker = BitbakeWorker(sys.stdin) |
366 | worker.serve() | 385 | if not profiling: |
386 | worker.serve() | ||
387 | else: | ||
388 | profname = "profile-worker.log" | ||
389 | prof = profile.Profile() | ||
390 | try: | ||
391 | profile.Profile.runcall(prof, worker.serve) | ||
392 | finally: | ||
393 | prof.dump_stats(profname) | ||
394 | bb.utils.process_profilelog(profname) | ||
367 | except BaseException as e: | 395 | except BaseException as e: |
368 | if not normalexit: | 396 | if not normalexit: |
369 | import traceback | 397 | import traceback |