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-27 14:58:53 +0100 |
commit | 446e490bf485b712e5cee733dab5805254cdcad0 (patch) | |
tree | ee5bad76056f9b49d9d901b369223a502ca7dd58 /bin/bitbake-worker | |
parent | 93d155f4766e27e7b004d13569aa03961fe89e3b (diff) | |
download | bitbake-446e490bf485b712e5cee733dab5805254cdcad0.tar.gz |
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.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bin/bitbake-worker')
-rwxr-xr-x | bin/bitbake-worker | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/bin/bitbake-worker b/bin/bitbake-worker index d1ff5b36c..c7992f7e8 100755 --- a/bin/bitbake-worker +++ b/bin/bitbake-worker @@ -12,10 +12,18 @@ import errno import signal # Users shouldn't be running this code directly -if len(sys.argv) != 2 or sys.argv[1] != "decafbad": +if len(sys.argv) != 2 or not sys.argv[1].startswith("decafbad"): print("bitbake-worker is meant for internal execution by bitbake itself, please don't use it standalone.") sys.exit(1) +profiling = False +if sys.argv[1] == "decafbadbad": + profiling = True + try: + import cProfile as profile + except: + import profile + logger = logging.getLogger("BitBake") try: @@ -134,6 +142,7 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat bb.msg.fatal("RunQueue", "fork failed: %d (%s)" % (e.errno, e.strerror)) if pid == 0: + def child(): global worker_pipe pipein.close() @@ -185,10 +194,20 @@ def fork_off_task(cfg, data, workerdata, fn, task, taskname, appends, taskdepdat os._exit(1) try: if not cfg.dry_run: - ret = bb.build.exec_task(fn, taskname, the_data, cfg.profile) - os._exit(ret) + return bb.build.exec_task(fn, taskname, the_data, cfg.profile) except: os._exit(1) + if not profiling: + os._exit(child()) + else: + profname = "profile-%s.log" % (fn.replace("/", "-") + "-" + taskname) + prof = profile.Profile() + try: + ret = profile.Profile.runcall(prof, child) + finally: + prof.dump_stats(profname) + bb.utils.process_profilelog(profname) + os._exit(ret) else: for key, value in envbackup.iteritems(): if value is None: @@ -363,7 +382,16 @@ class BitbakeWorker(object): try: worker = BitbakeWorker(sys.stdin) - worker.serve() + if not profiling: + worker.serve() + else: + profname = "profile-worker.log" + prof = profile.Profile() + try: + profile.Profile.runcall(prof, worker.serve) + finally: + prof.dump_stats(profname) + bb.utils.process_profilelog(profname) except BaseException as e: if not normalexit: import traceback |