diff options
| author | Alexander Kanavin <alex.kanavin@gmail.com> | 2022-02-06 22:53:11 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-02-08 14:20:18 +0000 |
| commit | 18f165c9e8e21a1e1acc148464f885adcdfeeb12 (patch) | |
| tree | 093317cabc8a6e29714f4dd2bc8562937c291588 | |
| parent | 1dfdf2bb92270982682312e893f939e78ef7eb53 (diff) | |
| download | poky-18f165c9e8e21a1e1acc148464f885adcdfeeb12.tar.gz | |
insane.bbclass: use multiprocessing for collecting 'objdump -p' output
This was prompted by ltp's unreasonably long package_qa times; it has
a massive amount of executables and insane runs objdump for all of
them, serially.
This reduces the time from 4 minutes to 1m20s on my machine.
(From OE-Core rev: fac984b99fdb46949879516cb87153860f402c75)
Signed-off-by: Alexander Kanavin <alex@linutronix.de>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
| -rw-r--r-- | meta/classes/insane.bbclass | 22 | ||||
| -rw-r--r-- | meta/lib/oe/qa.py | 6 |
2 files changed, 26 insertions, 2 deletions
diff --git a/meta/classes/insane.bbclass b/meta/classes/insane.bbclass index 11532ecd08..a13a947bcf 100644 --- a/meta/classes/insane.bbclass +++ b/meta/classes/insane.bbclass | |||
| @@ -684,6 +684,10 @@ def package_qa_recipe(warnfuncs, errorfuncs, pn, d): | |||
| 684 | 684 | ||
| 685 | return len(errors) == 0 | 685 | return len(errors) == 0 |
| 686 | 686 | ||
| 687 | def prepopulate_objdump_p(elf, d): | ||
| 688 | output = elf.run_objdump("-p", d) | ||
| 689 | return (elf.name, output) | ||
| 690 | |||
| 687 | # Walk over all files in a directory and call func | 691 | # Walk over all files in a directory and call func |
| 688 | def package_qa_walk(warnfuncs, errorfuncs, package, d): | 692 | def package_qa_walk(warnfuncs, errorfuncs, package, d): |
| 689 | #if this will throw an exception, then fix the dict above | 693 | #if this will throw an exception, then fix the dict above |
| @@ -692,18 +696,32 @@ def package_qa_walk(warnfuncs, errorfuncs, package, d): | |||
| 692 | 696 | ||
| 693 | warnings = {} | 697 | warnings = {} |
| 694 | errors = {} | 698 | errors = {} |
| 699 | elves = {} | ||
| 695 | for path in pkgfiles[package]: | 700 | for path in pkgfiles[package]: |
| 696 | elf = None | 701 | elf = None |
| 697 | if os.path.isfile(path): | 702 | if os.path.isfile(path): |
| 698 | elf = oe.qa.ELFFile(path) | 703 | elf = oe.qa.ELFFile(path) |
| 699 | try: | 704 | try: |
| 700 | elf.open() | 705 | elf.open() |
| 706 | elf.close() | ||
| 701 | except oe.qa.NotELFFileError: | 707 | except oe.qa.NotELFFileError: |
| 702 | elf = None | 708 | elf = None |
| 709 | if elf: | ||
| 710 | elves[path] = elf | ||
| 711 | |||
| 712 | results = oe.utils.multiprocess_launch(prepopulate_objdump_p, elves.values(), d, extraargs=(d,)) | ||
| 713 | for item in results: | ||
| 714 | elves[item[0]].set_objdump("-p", item[1]) | ||
| 715 | |||
| 716 | for path in pkgfiles[package]: | ||
| 717 | if path in elves: | ||
| 718 | elves[path].open() | ||
| 703 | for func in warnfuncs: | 719 | for func in warnfuncs: |
| 704 | func(path, package, d, elf, warnings) | 720 | func(path, package, d, elves.get(path), warnings) |
| 705 | for func in errorfuncs: | 721 | for func in errorfuncs: |
| 706 | func(path, package, d, elf, errors) | 722 | func(path, package, d, elves.get(path), errors) |
| 723 | if path in elves: | ||
| 724 | elves[path].close() | ||
| 707 | 725 | ||
| 708 | for w in warnings: | 726 | for w in warnings: |
| 709 | oe.qa.handle_error(w, warnings[w], d) | 727 | oe.qa.handle_error(w, warnings[w], d) |
diff --git a/meta/lib/oe/qa.py b/meta/lib/oe/qa.py index efab7e8564..89acd3ead0 100644 --- a/meta/lib/oe/qa.py +++ b/meta/lib/oe/qa.py | |||
| @@ -48,6 +48,9 @@ class ELFFile: | |||
| 48 | return self | 48 | return self |
| 49 | 49 | ||
| 50 | def __exit__(self, exc_type, exc_value, traceback): | 50 | def __exit__(self, exc_type, exc_value, traceback): |
| 51 | self.close() | ||
| 52 | |||
| 53 | def close(self): | ||
| 51 | if self.data: | 54 | if self.data: |
| 52 | self.data.close() | 55 | self.data.close() |
| 53 | 56 | ||
| @@ -128,6 +131,9 @@ class ELFFile: | |||
| 128 | """ | 131 | """ |
| 129 | return self.getShort(ELFFile.E_MACHINE) | 132 | return self.getShort(ELFFile.E_MACHINE) |
| 130 | 133 | ||
| 134 | def set_objdump(self, cmd, output): | ||
| 135 | self.objdump_output[cmd] = output | ||
| 136 | |||
| 131 | def run_objdump(self, cmd, d): | 137 | def run_objdump(self, cmd, d): |
| 132 | import bb.process | 138 | import bb.process |
| 133 | import sys | 139 | import sys |
