diff options
author | Patrick Ohly <patrick.ohly@intel.com> | 2017-01-13 15:52:33 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-01-20 11:53:49 +0000 |
commit | 90f1ef88d61f27f446286b6a1dc638ac093d8ba7 (patch) | |
tree | 35bc5e1f1798c4f553c5e1fffe507ebf3e764a84 /meta/classes | |
parent | ce84432d983dde8f5616727712ac7231e20c4d1b (diff) | |
download | poky-90f1ef88d61f27f446286b6a1dc638ac093d8ba7.tar.gz |
rm_work.bbclass: clean up sooner
Having do_rm_work depend on do_build had one major disadvantage:
do_build depends on the do_build of other recipes, to ensure that
runtime dependencies also get built. The effect is that when work on a
recipe is complete and it could get cleaned up, do_rm_work still
doesn't run because it waits for those other recipes, thus leading to
more temporary disk space usage than really needed.
The right solution is to inject do_rm_work before do_build and after
all tasks of the recipe. Achieving that depends on the new bitbake
bb.event.RecipeTaskPreProcess and bb.build.preceedtask().
It can't just run in an anonymous function, because other anonymous
functions that run later may add more tasks. There's still such a
potential conflict when some future RecipeTaskPreProcess event handler
also wants to change task dependencies, but that's not a problem
now. Should it ever occur, the two handlers will have to know about
each other and cooperate to resolve the conflict.
Benchmarking (see "rm_work + pybootchart enhancements" on the OE-core
mailing list) showed that builds with the modified rm_work.bbclass
were both faster (albeit not by much) and required considerably less
disk space (14230MiB instead of 18740MiB for core-image-sato).
Interestingly enough, builds with rm_work.bbclass were also faster
than those without.
(From OE-Core rev: 936179754c8d0f98e1196ddc6796fdfd72c0c3b4)
Signed-off-by: Patrick Ohly <patrick.ohly@intel.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/classes')
-rw-r--r-- | meta/classes/rm_work.bbclass | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/meta/classes/rm_work.bbclass b/meta/classes/rm_work.bbclass index 9b7220fc2b..054c93716e 100644 --- a/meta/classes/rm_work.bbclass +++ b/meta/classes/rm_work.bbclass | |||
@@ -26,9 +26,6 @@ BB_SCHEDULER ?= "completion" | |||
26 | # Run the rm_work task in the idle scheduling class | 26 | # Run the rm_work task in the idle scheduling class |
27 | BB_TASK_IONICE_LEVEL_task-rm_work = "3.0" | 27 | BB_TASK_IONICE_LEVEL_task-rm_work = "3.0" |
28 | 28 | ||
29 | RMWORK_ORIG_TASK := "${BB_DEFAULT_TASK}" | ||
30 | BB_DEFAULT_TASK = "rm_work_all" | ||
31 | |||
32 | do_rm_work () { | 29 | do_rm_work () { |
33 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. | 30 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. |
34 | for p in ${RM_WORK_EXCLUDE}; do | 31 | for p in ${RM_WORK_EXCLUDE}; do |
@@ -105,13 +102,6 @@ do_rm_work () { | |||
105 | rm -f $i | 102 | rm -f $i |
106 | done | 103 | done |
107 | } | 104 | } |
108 | addtask rm_work after do_${RMWORK_ORIG_TASK} | ||
109 | |||
110 | do_rm_work_all () { | ||
111 | : | ||
112 | } | ||
113 | do_rm_work_all[recrdeptask] = "do_rm_work" | ||
114 | addtask rm_work_all after do_rm_work | ||
115 | 105 | ||
116 | do_populate_sdk[postfuncs] += "rm_work_populatesdk" | 106 | do_populate_sdk[postfuncs] += "rm_work_populatesdk" |
117 | rm_work_populatesdk () { | 107 | rm_work_populatesdk () { |
@@ -125,7 +115,13 @@ rm_work_rootfs () { | |||
125 | } | 115 | } |
126 | rm_work_rootfs[cleandirs] = "${WORKDIR}/rootfs" | 116 | rm_work_rootfs[cleandirs] = "${WORKDIR}/rootfs" |
127 | 117 | ||
128 | python () { | 118 | # We have to add the do_rmwork task already now, because all tasks are |
119 | # meant to be defined before the RecipeTaskPreProcess event triggers. | ||
120 | # The inject_rm_work event handler then merely changes task dependencies. | ||
121 | addtask do_rm_work | ||
122 | addhandler inject_rm_work | ||
123 | inject_rm_work[eventmask] = "bb.event.RecipeTaskPreProcess" | ||
124 | python inject_rm_work() { | ||
129 | if bb.data.inherits_class('kernel', d): | 125 | if bb.data.inherits_class('kernel', d): |
130 | d.appendVar("RM_WORK_EXCLUDE", ' ' + d.getVar("PN")) | 126 | d.appendVar("RM_WORK_EXCLUDE", ' ' + d.getVar("PN")) |
131 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. | 127 | # If the recipe name is in the RM_WORK_EXCLUDE, skip the recipe. |
@@ -134,4 +130,17 @@ python () { | |||
134 | if pn in excludes: | 130 | if pn in excludes: |
135 | d.delVarFlag('rm_work_rootfs', 'cleandirs') | 131 | d.delVarFlag('rm_work_rootfs', 'cleandirs') |
136 | d.delVarFlag('rm_work_populatesdk', 'cleandirs') | 132 | d.delVarFlag('rm_work_populatesdk', 'cleandirs') |
133 | else: | ||
134 | # Inject do_rm_work into the tasks of the current recipe such that do_build | ||
135 | # depends on it and that it runs after all other tasks that block do_build, | ||
136 | # i.e. after all work on the current recipe is done. The reason for taking | ||
137 | # this approach instead of making do_rm_work depend on do_build is that | ||
138 | # do_build inherits additional runtime dependencies on | ||
139 | # other recipes and thus will typically run much later than completion of | ||
140 | # work in the recipe itself. | ||
141 | deps = bb.build.preceedtask('do_build', True, d) | ||
142 | if 'do_build' in deps: | ||
143 | deps.remove('do_build') | ||
144 | # In practice, addtask() here merely updates the dependencies. | ||
145 | bb.build.addtask('do_rm_work', 'do_build', ' '.join(deps), d) | ||
137 | } | 146 | } |