summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2020-01-07 22:08:57 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-01-28 11:51:10 (GMT)
commit2bd2f56d4163218662b01712feff9719ace66e31 (patch)
tree77aab576e7a9d00b3c4f7282117b986929b171c4
parent4fc93977e9ab8d5cf63f383a77610515bd3f032e (diff)
downloadpoky-2bd2f56d4163218662b01712feff9719ace66e31.tar.gz
bitbake: cooker: Keep track of watched files using a set instead of a list
When there are many watched files, keeping track of them using lists is suboptimal. Using sets improves the performance considerably. (Bitbake rev: aa770081d7d3ff678b18117a4b4e9b3da09b72be) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org> (cherry picked from commit 1e96df260e47d160dbd36bfc92c31ef06266f662) Signed-off-by: Armin Kuster <akuster808@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/cooker.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index a97bafd..77d18a5 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -171,8 +171,8 @@ class BBCooker:
171 bb.debug(1, "BBCooker pyinotify1 %s" % time.time()) 171 bb.debug(1, "BBCooker pyinotify1 %s" % time.time())
172 sys.stdout.flush() 172 sys.stdout.flush()
173 173
174 self.configwatcher.bbseen = [] 174 self.configwatcher.bbseen = set()
175 self.configwatcher.bbwatchedfiles = [] 175 self.configwatcher.bbwatchedfiles = set()
176 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) 176 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications)
177 bb.debug(1, "BBCooker pyinotify2 %s" % time.time()) 177 bb.debug(1, "BBCooker pyinotify2 %s" % time.time())
178 sys.stdout.flush() 178 sys.stdout.flush()
@@ -182,8 +182,8 @@ class BBCooker:
182 self.watcher = pyinotify.WatchManager() 182 self.watcher = pyinotify.WatchManager()
183 bb.debug(1, "BBCooker pyinotify3 %s" % time.time()) 183 bb.debug(1, "BBCooker pyinotify3 %s" % time.time())
184 sys.stdout.flush() 184 sys.stdout.flush()
185 self.watcher.bbseen = [] 185 self.watcher.bbseen = set()
186 self.watcher.bbwatchedfiles = [] 186 self.watcher.bbwatchedfiles = set()
187 self.notifier = pyinotify.Notifier(self.watcher, self.notifications) 187 self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
188 188
189 bb.debug(1, "BBCooker pyinotify complete %s" % time.time()) 189 bb.debug(1, "BBCooker pyinotify complete %s" % time.time())
@@ -278,14 +278,14 @@ class BBCooker:
278 if not watcher: 278 if not watcher:
279 watcher = self.watcher 279 watcher = self.watcher
280 for i in deps: 280 for i in deps:
281 watcher.bbwatchedfiles.append(i[0]) 281 watcher.bbwatchedfiles.add(i[0])
282 if dirs: 282 if dirs:
283 f = i[0] 283 f = i[0]
284 else: 284 else:
285 f = os.path.dirname(i[0]) 285 f = os.path.dirname(i[0])
286 if f in watcher.bbseen: 286 if f in watcher.bbseen:
287 continue 287 continue
288 watcher.bbseen.append(f) 288 watcher.bbseen.add(f)
289 watchtarget = None 289 watchtarget = None
290 while True: 290 while True:
291 # We try and add watches for files that don't exist but if they did, would influence 291 # We try and add watches for files that don't exist but if they did, would influence
@@ -294,7 +294,7 @@ class BBCooker:
294 try: 294 try:
295 watcher.add_watch(f, self.watchmask, quiet=False) 295 watcher.add_watch(f, self.watchmask, quiet=False)
296 if watchtarget: 296 if watchtarget:
297 watcher.bbwatchedfiles.append(watchtarget) 297 watcher.bbwatchedfiles.add(watchtarget)
298 break 298 break
299 except pyinotify.WatchManagerError as e: 299 except pyinotify.WatchManagerError as e:
300 if 'ENOENT' in str(e): 300 if 'ENOENT' in str(e):
@@ -302,7 +302,7 @@ class BBCooker:
302 f = os.path.dirname(f) 302 f = os.path.dirname(f)
303 if f in watcher.bbseen: 303 if f in watcher.bbseen:
304 break 304 break
305 watcher.bbseen.append(f) 305 watcher.bbseen.add(f)
306 continue 306 continue
307 if 'ENOSPC' in str(e): 307 if 'ENOSPC' in str(e):
308 providerlog.error("No space left on device or exceeds fs.inotify.max_user_watches?") 308 providerlog.error("No space left on device or exceeds fs.inotify.max_user_watches?")