summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorPeter Kjellerstedt <peter.kjellerstedt@axis.com>2020-01-07 23:08:57 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-01-10 09:27:15 +0000
commit1f383c6a06d6ffc736a4c451cf7c8c6ce4759e11 (patch)
tree7e8483dbbfa7c10a1149a47930c2253b623017e4 /bitbake
parent4e85a7a0ccf20a005df7349cabe75faa49fe05b7 (diff)
downloadpoky-1f383c6a06d6ffc736a4c451cf7c8c6ce4759e11.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: 1e96df260e47d160dbd36bfc92c31ef06266f662) Signed-off-by: Peter Kjellerstedt <peter.kjellerstedt@axis.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-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 e6442bff93..b74affa7ec 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -169,8 +169,8 @@ class BBCooker:
169 bb.debug(1, "BBCooker pyinotify1 %s" % time.time()) 169 bb.debug(1, "BBCooker pyinotify1 %s" % time.time())
170 sys.stdout.flush() 170 sys.stdout.flush()
171 171
172 self.configwatcher.bbseen = [] 172 self.configwatcher.bbseen = set()
173 self.configwatcher.bbwatchedfiles = [] 173 self.configwatcher.bbwatchedfiles = set()
174 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications) 174 self.confignotifier = pyinotify.Notifier(self.configwatcher, self.config_notifications)
175 bb.debug(1, "BBCooker pyinotify2 %s" % time.time()) 175 bb.debug(1, "BBCooker pyinotify2 %s" % time.time())
176 sys.stdout.flush() 176 sys.stdout.flush()
@@ -180,8 +180,8 @@ class BBCooker:
180 self.watcher = pyinotify.WatchManager() 180 self.watcher = pyinotify.WatchManager()
181 bb.debug(1, "BBCooker pyinotify3 %s" % time.time()) 181 bb.debug(1, "BBCooker pyinotify3 %s" % time.time())
182 sys.stdout.flush() 182 sys.stdout.flush()
183 self.watcher.bbseen = [] 183 self.watcher.bbseen = set()
184 self.watcher.bbwatchedfiles = [] 184 self.watcher.bbwatchedfiles = set()
185 self.notifier = pyinotify.Notifier(self.watcher, self.notifications) 185 self.notifier = pyinotify.Notifier(self.watcher, self.notifications)
186 186
187 bb.debug(1, "BBCooker pyinotify complete %s" % time.time()) 187 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?")