summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/event.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-23 15:55:21 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-08-23 17:29:54 +0100
commit25e410b743be45f7ed57457c1d3cd2066652085b (patch)
tree51035c334025e08e2500912026e97014e81803cd /bitbake/lib/bb/event.py
parent9f0f799c461fb67e7c03304216253ca9bf899680 (diff)
downloadpoky-25e410b743be45f7ed57457c1d3cd2066652085b.tar.gz
bitbake: event/msg: Add primitive server side UI log record filtering
Currently one of the bigger bottlenecks in bitbake is passing all the log messages over IPC to the UI. This is worthwhile if the UI is going to use them, pointless otherwise. The memory resident bitbake suffers from this performance issue particularly badly. This patch filters the log events on the server side with the global log levels and hence reduces the traffic. This speeds up parsing (18.5s down to 17s) and bitbake general command overhead is reduced (7.3s for a NOP to 6.2s). What isn't added here is general event filtering or the ability to change the log levels once set. Provision is made for adding this in a follow up patch though. (Bitbake rev: 1bf0e88f57ba0bca62532e81d0d62cf88e2abcbb) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/event.py')
-rw-r--r--bitbake/lib/bb/event.py25
1 files changed, 25 insertions, 0 deletions
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index ba25d38d89..8ffd2c3e18 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -63,6 +63,7 @@ def clean_class_handlers():
63# Internal 63# Internal
64_handlers = clean_class_handlers() 64_handlers = clean_class_handlers()
65_ui_handlers = {} 65_ui_handlers = {}
66_ui_logfilters = {}
66_ui_handler_seq = 0 67_ui_handler_seq = 0
67_event_handler_map = {} 68_event_handler_map = {}
68_catchall_handlers = {} 69_catchall_handlers = {}
@@ -135,6 +136,8 @@ def fire_ui_handlers(event, d):
135 for h in _ui_handlers: 136 for h in _ui_handlers:
136 #print "Sending event %s" % event 137 #print "Sending event %s" % event
137 try: 138 try:
139 if not _ui_logfilters[h].filter(event):
140 continue
138 # We use pickle here since it better handles object instances 141 # We use pickle here since it better handles object instances
139 # which xmlrpc's marshaller does not. Events *must* be serializable 142 # which xmlrpc's marshaller does not. Events *must* be serializable
140 # by pickle. 143 # by pickle.
@@ -207,6 +210,8 @@ def remove(name, handler):
207def register_UIHhandler(handler): 210def register_UIHhandler(handler):
208 bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1 211 bb.event._ui_handler_seq = bb.event._ui_handler_seq + 1
209 _ui_handlers[_ui_handler_seq] = handler 212 _ui_handlers[_ui_handler_seq] = handler
213 level, debug_domains = bb.msg.constructLogOptions()
214 _ui_logfilters[_ui_handler_seq] = UIEventFilter(level, debug_domains)
210 return _ui_handler_seq 215 return _ui_handler_seq
211 216
212def unregister_UIHhandler(handlerNum): 217def unregister_UIHhandler(handlerNum):
@@ -214,6 +219,26 @@ def unregister_UIHhandler(handlerNum):
214 del _ui_handlers[handlerNum] 219 del _ui_handlers[handlerNum]
215 return 220 return
216 221
222# Class to allow filtering of events and specific filtering of LogRecords *before* we put them over the IPC
223class UIEventFilter(object):
224 def __init__(self, level, debug_domains):
225 self.update(None, level, debug_domains)
226
227 def update(self, eventmask, level, debug_domains):
228 self.eventmask = None
229 self.stdlevel = level
230 self.debug_domains = debug_domains
231
232 def filter(self, event):
233 if isinstance(event, logging.LogRecord):
234 if event.levelno >= self.stdlevel:
235 return True
236 if event.name in self.debug_domains and event.levelno >= self.debug_domains[event.name]:
237 return True
238 return False
239 # Implement other event masking here on self.eventmask
240 return True
241
217def getName(e): 242def getName(e):
218 """Returns the name of a class or class instance""" 243 """Returns the name of a class or class instance"""
219 if getattr(e, "__name__", None) == None: 244 if getattr(e, "__name__", None) == None: