From 16cbb7cb91a5b59e9c9907b64b2e02d7027ea5c0 Mon Sep 17 00:00:00 2001 From: Tom Pollard Date: Wed, 4 Dec 2019 13:49:47 +0000 Subject: userconfig.yaml: Add bool for disabling console output throttling Also highlight the change & configuration in NEWS --- NEWS | 10 ++++++++++ src/buildstream/_context.py | 15 ++++++++++++++- src/buildstream/_frontend/app.py | 8 ++++++-- src/buildstream/data/userconfig.yaml | 3 +++ 4 files changed, 33 insertions(+), 3 deletions(-) diff --git a/NEWS b/NEWS index 602b14b51..293085cfe 100644 --- a/NEWS +++ b/NEWS @@ -20,6 +20,16 @@ API Plugins authors that do this and believe BuildStream should be testing that part of their plugins should open an issue on BuildStream. +Miscellaneous +------------- + + o By default the update rate of builstream console output + (e.g. messages & status updates) when executing a scheduler driven task is + restricted to once per second, known as the tick, with messages being batched + in the intervening periods if necessary. This restriction can be lifted with + `throttle-ui-updates: False` in user configuration. Logging behaviour remains + unaffected by this configuration. + ================== buildstream 1.91.3 diff --git a/src/buildstream/_context.py b/src/buildstream/_context.py index 9642edd49..513754a4c 100644 --- a/src/buildstream/_context.py +++ b/src/buildstream/_context.py @@ -114,6 +114,9 @@ class Context: # Format string for printing message lines in the master log self.log_message_format = None + # Wether to rate limit the updating of the bst output where applicable + self.log_throttle_updates = None + # Maximum number of fetch or refresh tasks self.sched_fetchers = None @@ -337,7 +340,16 @@ class Context: # Load logging config logging = defaults.get_mapping("logging") logging.validate_keys( - ["key-length", "verbose", "error-lines", "message-lines", "debug", "element-format", "message-format"] + [ + "key-length", + "verbose", + "error-lines", + "message-lines", + "debug", + "element-format", + "message-format", + "throttle-ui-updates", + ] ) self.log_key_length = logging.get_int("key-length") self.log_debug = logging.get_bool("debug") @@ -346,6 +358,7 @@ class Context: self.log_message_lines = logging.get_int("message-lines") self.log_element_format = logging.get_str("element-format") self.log_message_format = logging.get_str("message-format") + self.log_throttle_updates = logging.get_bool("throttle-ui-updates") # Load scheduler config scheduler = defaults.get_mapping("scheduler") diff --git a/src/buildstream/_frontend/app.py b/src/buildstream/_frontend/app.py index b7aeb040b..cd05b7f8d 100644 --- a/src/buildstream/_frontend/app.py +++ b/src/buildstream/_frontend/app.py @@ -91,6 +91,7 @@ class App: # Cached messages self._message_text = "" + self._cache_messages = None # # Early initialization @@ -239,6 +240,9 @@ class App: # Propagate pipeline feedback to the user self.context.messenger.set_message_handler(self._message_handler) + # Check if throttling frontend updates to tick rate + self._cache_messages = self.context.log_throttle_updates + # Allow the Messenger to write status messages self.context.messenger.set_render_status_cb(self._render) @@ -803,8 +807,8 @@ class App: text = self.logger.render(message) self._message_text += text - # If scheduler tick isn't active then render - if not self.stream.running: + # If we're not rate limiting messaging, or the scheduler tick isn't active then render + if not self._cache_messages or not self.stream.running: self._render(message_text=self._message_text) # Additionally log to a file diff --git a/src/buildstream/data/userconfig.yaml b/src/buildstream/data/userconfig.yaml index dc31c10ce..5b568167b 100644 --- a/src/buildstream/data/userconfig.yaml +++ b/src/buildstream/data/userconfig.yaml @@ -133,3 +133,6 @@ logging: message-format: | [%{elapsed}][%{key}][%{element}] %{action} %{message} + + # Limit bst console output update rate to 1Hz where applicable + throttle-ui-updates: True -- cgit v1.2.1