diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-01 11:29:06 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-01 18:02:12 +0000 |
commit | 85e9af9d78757e992f0d91da5909fb59d1591ebe (patch) | |
tree | c092cb50850b1c9ac4ffb5a95c27bd86ba318596 /meta/classes | |
parent | 758f18167f2ed50576265a0bab7ec529c69656fa (diff) | |
download | poky-85e9af9d78757e992f0d91da5909fb59d1591ebe.tar.gz |
staging: Reduce the number of mkdirs calls
The number of mkdir calls was showing up high on the profile charts since
it was getting called once per file which is excessive. Each call results
in one or more syscalls which is bad for performance. Cache which
directories we've seen to reduce the calls to a more reasonable number
and speed up recipe specific sysroots.
(From OE-Core rev: 680fb343be5d0a7f9abbe9c75ca232abe5871663)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/staging.bbclass | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/meta/classes/staging.bbclass b/meta/classes/staging.bbclass index 35e53fe2b2..93d31ebb51 100644 --- a/meta/classes/staging.bbclass +++ b/meta/classes/staging.bbclass | |||
@@ -244,7 +244,7 @@ python do_populate_sysroot_setscene () { | |||
244 | } | 244 | } |
245 | addtask do_populate_sysroot_setscene | 245 | addtask do_populate_sysroot_setscene |
246 | 246 | ||
247 | def staging_copyfile(c, target, fixme, postinsts, stagingdir): | 247 | def staging_copyfile(c, target, fixme, postinsts, stagingdir, seendirs): |
248 | import errno | 248 | import errno |
249 | 249 | ||
250 | if c.endswith("/fixmepath"): | 250 | if c.endswith("/fixmepath"): |
@@ -255,7 +255,10 @@ def staging_copyfile(c, target, fixme, postinsts, stagingdir): | |||
255 | #bb.warn(c) | 255 | #bb.warn(c) |
256 | dest = c.replace(stagingdir, "") | 256 | dest = c.replace(stagingdir, "") |
257 | dest = target + "/" + "/".join(dest.split("/")[3:]) | 257 | dest = target + "/" + "/".join(dest.split("/")[3:]) |
258 | bb.utils.mkdirhier(os.path.dirname(dest)) | 258 | destdir = os.path.dirname(dest) |
259 | if destdir not in seendirs: | ||
260 | bb.utils.mkdirhier(destdir) | ||
261 | seendirs.add(destdir) | ||
259 | if "/usr/bin/postinst-" in c: | 262 | if "/usr/bin/postinst-" in c: |
260 | postinsts.append(dest) | 263 | postinsts.append(dest) |
261 | if os.path.islink(c): | 264 | if os.path.islink(c): |
@@ -278,10 +281,12 @@ def staging_copyfile(c, target, fixme, postinsts, stagingdir): | |||
278 | raise | 281 | raise |
279 | return dest | 282 | return dest |
280 | 283 | ||
281 | def staging_copydir(c, target, stagingdir): | 284 | def staging_copydir(c, target, stagingdir, seendirs): |
282 | dest = c.replace(stagingdir, "") | 285 | dest = c.replace(stagingdir, "") |
283 | dest = target + "/" + "/".join(dest.split("/")[3:]) | 286 | dest = target + "/" + "/".join(dest.split("/")[3:]) |
284 | bb.utils.mkdirhier(dest) | 287 | if dest not in seendirs: |
288 | bb.utils.mkdirhier(dest) | ||
289 | seendirs.add(dest) | ||
285 | 290 | ||
286 | def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d): | 291 | def staging_processfixme(fixme, target, recipesysroot, recipesysrootnative, d): |
287 | import subprocess | 292 | import subprocess |
@@ -302,6 +307,7 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d): | |||
302 | 307 | ||
303 | fixme = [] | 308 | fixme = [] |
304 | postinsts = [] | 309 | postinsts = [] |
310 | seendirs = set() | ||
305 | stagingdir = d.getVar("STAGING_DIR") | 311 | stagingdir = d.getVar("STAGING_DIR") |
306 | if native: | 312 | if native: |
307 | pkgarchs = ['${BUILD_ARCH}', '${BUILD_ARCH}_*'] | 313 | pkgarchs = ['${BUILD_ARCH}', '${BUILD_ARCH}_*'] |
@@ -332,10 +338,10 @@ def staging_populate_sysroot_dir(targetsysroot, nativesysroot, native, d): | |||
332 | for l in f: | 338 | for l in f: |
333 | l = l.strip() | 339 | l = l.strip() |
334 | if l.endswith("/"): | 340 | if l.endswith("/"): |
335 | staging_copydir(l, targetdir, stagingdir) | 341 | staging_copydir(l, targetdir, stagingdir, seendirs) |
336 | continue | 342 | continue |
337 | try: | 343 | try: |
338 | staging_copyfile(l, targetdir, fixme, postinsts, stagingdir) | 344 | staging_copyfile(l, targetdir, fixme, postinsts, stagingdir, seendirs) |
339 | except FileExistsError: | 345 | except FileExistsError: |
340 | continue | 346 | continue |
341 | 347 | ||
@@ -492,6 +498,7 @@ python extend_recipe_sysroot() { | |||
492 | fixme = {} | 498 | fixme = {} |
493 | fixme[''] = [] | 499 | fixme[''] = [] |
494 | fixme['native'] = [] | 500 | fixme['native'] = [] |
501 | seendirs = set() | ||
495 | postinsts = [] | 502 | postinsts = [] |
496 | multilibs = {} | 503 | multilibs = {} |
497 | manifests = {} | 504 | manifests = {} |
@@ -570,14 +577,14 @@ python extend_recipe_sysroot() { | |||
570 | l = l.strip() | 577 | l = l.strip() |
571 | if l.endswith("/"): | 578 | if l.endswith("/"): |
572 | if native: | 579 | if native: |
573 | dest = staging_copydir(l, recipesysrootnative, stagingdir) | 580 | dest = staging_copydir(l, recipesysrootnative, stagingdir, seendirs) |
574 | else: | 581 | else: |
575 | dest = staging_copydir(l, destsysroot, stagingdir) | 582 | dest = staging_copydir(l, destsysroot, stagingdir, seendirs) |
576 | continue | 583 | continue |
577 | if native: | 584 | if native: |
578 | dest = staging_copyfile(l, recipesysrootnative, fixme['native'], postinsts, stagingdir) | 585 | dest = staging_copyfile(l, recipesysrootnative, fixme['native'], postinsts, stagingdir, seendirs) |
579 | else: | 586 | else: |
580 | dest = staging_copyfile(l, destsysroot, fixme[''], postinsts, stagingdir) | 587 | dest = staging_copyfile(l, destsysroot, fixme[''], postinsts, stagingdir, seendirs) |
581 | if dest: | 588 | if dest: |
582 | m.write(dest.replace(workdir + "/", "") + "\n") | 589 | m.write(dest.replace(workdir + "/", "") + "\n") |
583 | 590 | ||