diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-04-03 08:57:17 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2022-04-03 17:51:26 +0100 |
commit | d0082265d5358f672ff00ff2d5c6a4d38564576e (patch) | |
tree | e369fa3f6c453dac9e959569d96c9ce780fead6f /bitbake/lib/bb | |
parent | 496cbc01ca0ffd2b582b9ab4c4e0f54db7b18b00 (diff) | |
download | poky-d0082265d5358f672ff00ff2d5c6a4d38564576e.tar.gz |
bitbake: cooker: Reset and rebuild inotify watches
The recent inotify changes can cause entire build trees to be monitored
which is suboptimal for performance.
Rather than trying increasingly convoluted tricks to try and handle add/removed
directories, rebuild the inotify watch when we reparse the configuration or
metadata.
(Bitbake rev: 3df322a200c28b45af1f2c92478c85eb7d20c38b)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/cooker.py | 54 |
1 files changed, 29 insertions, 25 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index df4acca18a..08593d114a 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -169,27 +169,15 @@ class BBCooker: | |||
169 | bb.debug(1, "BBCooker starting %s" % time.time()) | 169 | bb.debug(1, "BBCooker starting %s" % time.time()) |
170 | sys.stdout.flush() | 170 | sys.stdout.flush() |
171 | 171 | ||
172 | self.configwatcher = pyinotify.WatchManager() | 172 | self.configwatcher = None |
173 | bb.debug(1, "BBCooker pyinotify1 %s" % time.time()) | 173 | self.confignotifier = None |
174 | sys.stdout.flush() | ||
175 | 174 | ||
176 | self.configwatcher.bbseen = set() | ||
177 | self.configwatcher.bbwatchedfiles = set() | ||
178 | self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) | ||
179 | bb.debug(1, "BBCooker pyinotify2 %s" % time.time()) | ||
180 | sys.stdout.flush() | ||
181 | self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ | 175 | self.watchmask = pyinotify.IN_CLOSE_WRITE | pyinotify.IN_CREATE | pyinotify.IN_DELETE | \ |
182 | pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ | 176 | pyinotify.IN_DELETE_SELF | pyinotify.IN_MODIFY | pyinotify.IN_MOVE_SELF | \ |
183 | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO | 177 | pyinotify.IN_MOVED_FROM | pyinotify.IN_MOVED_TO |
184 | self.watcher = pyinotify.WatchManager() | ||
185 | bb.debug(1, "BBCooker pyinotify3 %s" % time.time()) | ||
186 | sys.stdout.flush() | ||
187 | self.watcher.bbseen = set() | ||
188 | self.watcher.bbwatchedfiles = set() | ||
189 | self.notifier = pyinotify.Notifier(self.watcher, self.notifications) | ||
190 | 178 | ||
191 | bb.debug(1, "BBCooker pyinotify complete %s" % time.time()) | 179 | self.watcher = None |
192 | sys.stdout.flush() | 180 | self.notifier = None |
193 | 181 | ||
194 | # If being called by something like tinfoil, we need to clean cached data | 182 | # If being called by something like tinfoil, we need to clean cached data |
195 | # which may now be invalid | 183 | # which may now be invalid |
@@ -240,9 +228,29 @@ class BBCooker: | |||
240 | sys.stdout.flush() | 228 | sys.stdout.flush() |
241 | self.handlePRServ() | 229 | self.handlePRServ() |
242 | 230 | ||
231 | def setupConfigWatcher(self): | ||
232 | if self.configwatcher: | ||
233 | self.configwatcher.close() | ||
234 | self.confignotifier = None | ||
235 | self.configwatcher = None | ||
236 | self.configwatcher = pyinotify.WatchManager() | ||
237 | self.configwatcher.bbseen = set() | ||
238 | self.configwatcher.bbwatchedfiles = set() | ||
239 | self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) | ||
240 | |||
241 | def setupParserWatcher(self): | ||
242 | if self.watcher: | ||
243 | self.watcher.close() | ||
244 | self.notifier = None | ||
245 | self.watcher = None | ||
246 | self.watcher = pyinotify.WatchManager() | ||
247 | self.watcher.bbseen = set() | ||
248 | self.watcher.bbwatchedfiles = set() | ||
249 | self.notifier = pyinotify.Notifier(self.watcher, self.notifications) | ||
250 | |||
243 | def process_inotify_updates(self): | 251 | def process_inotify_updates(self): |
244 | for n in [self.confignotifier, self.notifier]: | 252 | for n in [self.confignotifier, self.notifier]: |
245 | if n.check_events(timeout=0): | 253 | if n and n.check_events(timeout=0): |
246 | # read notified events and enqeue them | 254 | # read notified events and enqeue them |
247 | n.read_events() | 255 | n.read_events() |
248 | n.process_events() | 256 | n.process_events() |
@@ -262,10 +270,6 @@ class BBCooker: | |||
262 | self.configwatcher.bbseen.remove(event.pathname) | 270 | self.configwatcher.bbseen.remove(event.pathname) |
263 | # Could remove all entries starting with the directory but for now... | 271 | # Could remove all entries starting with the directory but for now... |
264 | bb.parse.clear_cache() | 272 | bb.parse.clear_cache() |
265 | if "IN_CREATE" in event.maskname: | ||
266 | self.add_filewatch([[event.pathname]], watcher=self.configwatcher, dirs=True) | ||
267 | elif "IN_DELETE" in event.maskname and event.pathname in self.configwatcher.bbseen: | ||
268 | self.configwatcher.bbseen.remove(event.pathname) | ||
269 | if not event.pathname in self.inotify_modified_files: | 273 | if not event.pathname in self.inotify_modified_files: |
270 | self.inotify_modified_files.append(event.pathname) | 274 | self.inotify_modified_files.append(event.pathname) |
271 | self.baseconfig_valid = False | 275 | self.baseconfig_valid = False |
@@ -285,10 +289,6 @@ class BBCooker: | |||
285 | self.watcher.bbseen.remove(event.pathname) | 289 | self.watcher.bbseen.remove(event.pathname) |
286 | # Could remove all entries starting with the directory but for now... | 290 | # Could remove all entries starting with the directory but for now... |
287 | bb.parse.clear_cache() | 291 | bb.parse.clear_cache() |
288 | if "IN_CREATE" in event.maskname: | ||
289 | self.add_filewatch([[event.pathname]], dirs=True) | ||
290 | elif "IN_DELETE" in event.maskname and event.pathname in self.watcher.bbseen: | ||
291 | self.watcher.bbseen.remove(event.pathname) | ||
292 | if not event.pathname in self.inotify_modified_files: | 292 | if not event.pathname in self.inotify_modified_files: |
293 | self.inotify_modified_files.append(event.pathname) | 293 | self.inotify_modified_files.append(event.pathname) |
294 | self.parsecache_valid = False | 294 | self.parsecache_valid = False |
@@ -358,6 +358,8 @@ class BBCooker: | |||
358 | if mod not in self.orig_sysmodules: | 358 | if mod not in self.orig_sysmodules: |
359 | del sys.modules[mod] | 359 | del sys.modules[mod] |
360 | 360 | ||
361 | self.setupConfigWatcher() | ||
362 | |||
361 | # Need to preserve BB_CONSOLELOG over resets | 363 | # Need to preserve BB_CONSOLELOG over resets |
362 | consolelog = None | 364 | consolelog = None |
363 | if hasattr(self, "data"): | 365 | if hasattr(self, "data"): |
@@ -1639,6 +1641,8 @@ class BBCooker: | |||
1639 | self.updateCacheSync() | 1641 | self.updateCacheSync() |
1640 | 1642 | ||
1641 | if self.state != state.parsing and not self.parsecache_valid: | 1643 | if self.state != state.parsing and not self.parsecache_valid: |
1644 | self.setupParserWatcher() | ||
1645 | |||
1642 | bb.parse.siggen.reset(self.data) | 1646 | bb.parse.siggen.reset(self.data) |
1643 | self.parseConfiguration () | 1647 | self.parseConfiguration () |
1644 | if CookerFeatures.SEND_SANITYEVENTS in self.featureset: | 1648 | if CookerFeatures.SEND_SANITYEVENTS in self.featureset: |