diff mbox series

[v3,3/4] bitbake: knotty: Use 40 Hz refresh rate (FPS) for footer update.

Message ID 20250125122752.649-4-egyszeregy@freemail.hu
State New
Headers show
Series bitbake: knotty/progressbar: Optimize footer update and prints. | expand

Commit Message

Livius Jan. 25, 2025, 12:27 p.m. UTC
s=20181004; d=freemail.hu;

	h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding;

	l=1985; bh=UgjLq2rOYnxJyFRcHguc0UUKUy6d0z7WKZnhmYaqtLE=;

	b=U9ntFV/sVOK8VnmARtCtpAXstiDNu3C3qjSZt5I4gWR4X1S4MD5VvXJNKIYO1uLt

	zEQ8rZ72Fj2AIqlWYW4U6YuGU2Wac/nKOFnYdx5NkzX1wJFLtETOBJiWwf3wz3tVKUD

	nRy/nznbimWPPVuAVzOdk2I3w1qMgjfPlcfXknpyYNxRgOs8HcWKZjQY5YO2lD5W57h

	R1ZWAt8fMEQ50lf5I23LE/2XT0crWjhpoMDzSO8HuU77SnyNAsbQysfNdmlA5OwVTGP

	xhuvCJF3Iogt8S/O9fmG8LOxmQY/M3p/2mbkgKDVUUvYhI9heVZWM5HJqPG8C5Uii11

	ed4i0QD/pg==
Content-Transfer-Encoding: quoted-printable

From: Benjamin Sz=C5=91ke <egyszeregy@freemail.hu>

Refresh footer in 40 Hz to avoid heavy print() flooding but keep it fluen=
t for human eyes.

Signed-off-by: Benjamin Sz=C5=91ke <egyszeregy@freemail.hu>
---
 lib/bb/ui/knotty.py | 24 ++++++++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

urrent =3D=3D self.helper.tasknumber_total) and not len(activetasks):
             self.clearFooter()
--=20
2.47.1.windows.2
diff mbox series

Patch

diff --git a/lib/bb/ui/knotty.py b/lib/bb/ui/knotty.py
index 416ea166f..bef45cad6 100644
--- a/lib/bb/ui/knotty.py
+++ b/lib/bb/ui/knotty.py
@@ -128,6 +128,10 @@  class InteractConsoleLogFilter(logging.Filter):
         return True
=20
 class TerminalFilter(object):
+
+    # 40 Hz (FPS) -> 0.025 secs
+    _DEFAULT_PRINT_INTERVAL =3D 0.025
+
     rows =3D 25
     columns =3D 80
=20
@@ -166,7 +170,7 @@  class TerminalFilter(object):
         self.interactive =3D sys.stdout.isatty()
         self.footer_present =3D False
         self.lastpids =3D []
-        self.lasttime =3D None
+        self.lasttime =3D time.time()
         self.quiet =3D quiet
=20
         self._footer_buf =3D io.StringIO()
@@ -251,11 +255,23 @@  class TerminalFilter(object):
         failedtasks =3D self.helper.failed_tasks
         runningpids =3D self.helper.running_pids
         currenttime =3D time.time()
-        if not self.lasttime or (currenttime - self.lasttime > 5):
+        deltatime =3D currenttime - self.lasttime
+
+        if (deltatime > 5.0):
             self.helper.needUpdate =3D True
-            self.lasttime =3D currenttime
-        if self.footer_present and not self.helper.needUpdate:
+            need_update =3D self.helper.needUpdate
+        else:
+            # Do not let to update faster then _DEFAULT_PRINT_INTERVAL
+            # to avoid heavy print() flooding.
+            need_update =3D 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 =3D currenttime
+
         self.helper.needUpdate =3D False
         if (not self.helper.tasknumber_total or self.helper.tasknumber_c=