summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-11-18 22:47:36 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:43 +0000
commit7c9444e9a58438058ec577bd8c2e51820c98072d (patch)
tree55074d2c00afa924707bb5b5d30b22bc6688594d /bitbake/lib/bb/cooker.py
parent95d2f56126d459b9e7f000d22ed7c1206d1a8f68 (diff)
downloadpoky-7c9444e9a58438058ec577bd8c2e51820c98072d.tar.gz
cache: sync the cache file to disk in the background
This version uses a thread rather than a process, to avoid problems with waitpid handling. This gives slightly less overall build time reduction than the separate process for it did (this reduces a -c compile coreutils-native by about 3 seconds, while the process reduced it by 7 seconds), however this time is quite insignificant relative to a typical build. The biggest issue with non-backgrounded syncing is the perceived delay before work begins, and this resolves that without breaking anything, or so it seems. (Bitbake rev: 5ab6c5c7b007b8c77c751582141afc07c183d672) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py31
1 files changed, 16 insertions, 15 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 0143c149b8..ac9758d402 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -25,6 +25,7 @@ from __future__ import print_function
25import sys, os, glob, os.path, re, time 25import sys, os, glob, os.path, re, time
26import logging 26import logging
27import sre_constants 27import sre_constants
28import threading
28import multiprocessing 29import multiprocessing
29import signal 30import signal
30from cStringIO import StringIO 31from cStringIO import StringIO
@@ -983,6 +984,7 @@ class CookerParser(object):
983 # Internal data 984 # Internal data
984 self.filelist = filelist 985 self.filelist = filelist
985 self.cooker = cooker 986 self.cooker = cooker
987 self.cfgdata = cooker.configuration.data
986 988
987 # Accounting statistics 989 # Accounting statistics
988 self.parsed = 0 990 self.parsed = 0
@@ -1006,7 +1008,6 @@ class CookerParser(object):
1006 self.result_queue = multiprocessing.Queue() 1008 self.result_queue = multiprocessing.Queue()
1007 1009
1008 self.fromcache = [] 1010 self.fromcache = []
1009 cfgdata = self.cooker.configuration.data
1010 for filename in self.filelist: 1011 for filename in self.filelist:
1011 appends = self.cooker.get_file_appends(filename) 1012 appends = self.cooker.get_file_appends(filename)
1012 if not self.cooker.bb_cache.cacheValid(filename): 1013 if not self.cooker.bb_cache.cacheValid(filename):
@@ -1021,13 +1022,13 @@ class CookerParser(object):
1021 output.put(infos) 1022 output.put(infos)
1022 1023
1023 self.processes = [] 1024 self.processes = []
1024 num_processes = int(cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or 1025 num_processes = int(self.cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or
1025 multiprocessing.cpu_count()) 1026 multiprocessing.cpu_count())
1026 for i in xrange(num_processes): 1027 for i in xrange(num_processes):
1027 process = multiprocessing.Process(target=worker, 1028 process = multiprocessing.Process(target=worker,
1028 args=(self.task_queue, 1029 args=(self.task_queue,
1029 self.result_queue, 1030 self.result_queue,
1030 cfgdata)) 1031 self.cfgdata))
1031 process.start() 1032 process.start()
1032 self.processes.append(process) 1033 self.processes.append(process)
1033 1034
@@ -1041,29 +1042,29 @@ class CookerParser(object):
1041 self.task_queue.close() 1042 self.task_queue.close()
1042 for process in self.processes: 1043 for process in self.processes:
1043 process.join() 1044 process.join()
1044 self.cooker.bb_cache.sync() 1045 threading.Thread(target=self.cooker.bb_cache.sync).start()
1045 bb.codeparser.parser_cache_save(self.cooker.configuration.data) 1046 threading.Thread(target=bb.codeparser.parser_cache_save(self.cooker.configuration.data)).start()
1046 if self.error > 0: 1047 if self.error > 0:
1047 raise ParsingErrorsFound() 1048 raise ParsingErrorsFound()
1048 1049
1049 def progress(self):
1050 bb.event.fire(bb.event.ParseProgress(self.cached, self.parsed,
1051 self.skipped, self.masked,
1052 self.virtuals, self.error,
1053 self.total),
1054 self.cooker.configuration.event_data)
1055
1056 def parse_next(self): 1050 def parse_next(self):
1057 cooker = self.cooker 1051 cooker = self.cooker
1058 if self.current >= self.total: 1052 if self.current >= self.total:
1053 event = bb.event.ParseCompleted(self.cached, self.parsed,
1054 self.skipped, self.masked,
1055 self.virtuals, self.error,
1056 self.total)
1057 bb.event.fire(event, self.cfgdata)
1059 self.shutdown() 1058 self.shutdown()
1060 return False 1059 return False
1060 elif self.current == 0:
1061 bb.event.fire(bb.event.ParseStarted(self.total, self.skipped, self.masked),
1062 self.cfgdata)
1061 1063
1062 try: 1064 try:
1063 if self.result_queue.empty() and self.fromcache: 1065 if self.result_queue.empty() and self.fromcache:
1064 filename, appends = self.fromcache.pop() 1066 filename, appends = self.fromcache.pop()
1065 _, infos = cooker.bb_cache.load(filename, appends, 1067 _, infos = cooker.bb_cache.load(filename, appends, self.cfgdata)
1066 self.cooker.configuration.data)
1067 parsed = False 1068 parsed = False
1068 else: 1069 else:
1069 infos = self.result_queue.get() 1070 infos = self.result_queue.get()
@@ -1087,7 +1088,7 @@ class CookerParser(object):
1087 if info.skipped: 1088 if info.skipped:
1088 self.skipped += 1 1089 self.skipped += 1
1089 finally: 1090 finally:
1090 self.progress() 1091 bb.event.fire(bb.event.ParseProgress(self.current), self.cfgdata)
1091 1092
1092 self.current += 1 1093 self.current += 1
1093 return True 1094 return True