From 48e771c4a6a21373d5070453cb1482e68b30ce56 Mon Sep 17 00:00:00 2001 From: Benjamin Szőke Date: Sat, 25 Jan 2025 13:27:51 +0100 Subject: bitbake: knotty: Use 40 Hz refresh rate (FPS) for footer update. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Refresh footer in 40 Hz to avoid heavy print() flooding but keep it fluent for human eyes. (Bitbake rev: c36efdf642d858c6997819744d00a3c1965c6417) Signed-off-by: Benjamin Szőke Signed-off-by: Mathieu Dubois-Briand Signed-off-by: Richard Purdie --- bitbake/lib/bb/ui/knotty.py | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'bitbake/lib') diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py index c4ab553a3a..732540b462 100644 --- a/bitbake/lib/bb/ui/knotty.py +++ b/bitbake/lib/bb/ui/knotty.py @@ -128,6 +128,10 @@ class InteractConsoleLogFilter(logging.Filter): return True class TerminalFilter(object): + + # 40 Hz (FPS) -> 0.025 secs + _DEFAULT_PRINT_INTERVAL = 0.025 + rows = 25 columns = 80 @@ -166,7 +170,7 @@ class TerminalFilter(object): self.interactive = sys.stdout.isatty() self.footer_present = False self.lastpids = [] - self.lasttime = None + self.lasttime = time.time() self.quiet = quiet self._footer_buf = io.StringIO() @@ -251,11 +255,23 @@ class TerminalFilter(object): failedtasks = self.helper.failed_tasks runningpids = self.helper.running_pids currenttime = time.time() - if not self.lasttime or (currenttime - self.lasttime > 5): + deltatime = currenttime - self.lasttime + + if (deltatime > 5.0): self.helper.needUpdate = True - self.lasttime = currenttime - if self.footer_present and not self.helper.needUpdate: + need_update = self.helper.needUpdate + else: + # Do not let to update faster then _DEFAULT_PRINT_INTERVAL + # to avoid heavy print() flooding. + need_update = self.helper.needUpdate and (deltatime > self._DEFAULT_PRINT_INTERVAL) + + if self.footer_present and (not need_update): + # Footer update is not need. return + else: + # Footer update is need and store its "lasttime" value. + self.lasttime = currenttime + self.helper.needUpdate = False if (not self.helper.tasknumber_total or self.helper.tasknumber_current == self.helper.tasknumber_total) and not len(activetasks): self.clearFooter() -- cgit v1.2.3-54-g00ecf