Skip to contentSkip to conversation

knotty: show elapsed time on the task progress bar

PATCH In review WXbet 4 participants 11 messages Aug 18 – Sep 5

lore
Share & tools
lore

WXbet

author
#0 lore raw

PATCH 1/1 knotty: show elapsed time on the task progress bar

As a convenience for the user, this makes it easy to see at a glance how long the current build has already been running.

The progress bar for the overall build currently shows only a percentage and a bar, with no running time — while each individual running-task line below it already carries an elapsed-time value. The patch adds a Timer widget to the bar, reusing knotty's existing time formatting so it matches the rest of the UI.

Thanks,
WXbet

From 9302e85e75edc6af22ea90336d2b0c46fa95fe80 Mon Sep 17 00:00:00 2001
From: WXbet <[email protected]>
Date: Tue, 18 Aug 2026 21:30:22 +0200
Subject: [PATCH] knotty: show elapsed time on the task progress bar

The progress bar for the overall build shows a percentage and a bar but no elapsed time, even though the individual running-task lines below it each show one.

Add a Timer widget to the bar. The time formatting in TerminalFilter.elapsed() is hoisted to a module-level bb_elapsed() helper and reused by a small progressbar.Timer subclass, so the bar prints the same "%dh%dm%ds" style as the rest of the UI.

---
 lib/bb/ui/knotty.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
lib/bb/ui/knotty.py +17 -11
index 15025e8dd..343045881 100644
@@ -37,6 +37,21 @@ featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS, bb.cooker.CookerFeatur
 logger = logging.getLogger("BitBake")
 interactive = sys.stdout.isatty()
 
+def bb_elapsed(sec):
+    hrs = int(sec / 3600.0)
+    sec -= hrs * 3600
+    min = int(sec / 60.0)
+    sec -= min * 60
+    if hrs > 0:
+        return "%dh%dm%ds" % (hrs, min, sec)
+    elif min > 0:
+        return "%dm%ds" % (min, sec)
+    else:
+        return "%ds" % (sec)
+
+class BBTimer(progressbar.Timer):
+    format_time = staticmethod(bb_elapsed)
+
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
         self.id = msg
@@ -250,16 +265,7 @@ class TerminalFilter(object):
         self._footer_lines = None
 
     def elapsed(self, sec):
-        hrs = int(sec / 3600.0)
-        sec -= hrs * 3600
-        min = int(sec / 60.0)
-        sec -= min * 60
-        if hrs > 0:
-            return "%dh%dm%ds" % (hrs, min, sec)
-        elif min > 0:
-            return "%dm%ds" % (min, sec)
-        else:
-            return "%ds" % (sec)
+        return bb_elapsed(sec)
 
     def keepAlive(self, t):
         if not self.cuu:
@@ -354,7 +360,7 @@ class TerminalFilter(object):
                 msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks)
             maxtask = self.helper.tasknumber_total
             if not self.main_progress or self.main_progress.maxval != maxtask:
-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', BBTimer(format='Elapsed: %s')]
                 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle)
                 self.main_progress.fd = self._footer_buf
                 self.main_progress.start(False)
Signature · 1 line
2.53.0
#2 lore raw

Can you please send this patch as an email per patch submission policy, because attachments are difficult to review and comment on?

Alex

Quoted 12 lines · WXbet via lists.openembedded.org

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group. View/Reply Online (#19985):
https://lists.openembedded.org/g/bitbake-devel/message/19985
Mute This Topic: https://lists.openembedded.org/mt/120819188/1686489
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [ [email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

#3 lore raw

PATCH 1/1 knotty: show elapsed time on the task progress bar

The progress bar for the overall build shows a percentage and a bar but no elapsed time, even though the individual running-task lines below it each show one.

Add a Timer widget to the bar. The time formatting in TerminalFilter.elapsed() is hoisted to a module-level bb_elapsed() helper and reused by a small progressbar.Timer subclass, so the bar prints the same "%dh%dm%ds" style as the rest of the UI.

---
 lib/bb/ui/knotty.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
lib/bb/ui/knotty.py +17 -11
index 15025e8dd..343045881 100644
@@ -37,6 +37,21 @@ featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS, bb.cooker.CookerFeatur
 logger = logging.getLogger("BitBake")
 interactive = sys.stdout.isatty()
 
+def bb_elapsed(sec):
+    hrs = int(sec / 3600.0)
+    sec -= hrs * 3600
+    min = int(sec / 60.0)
+    sec -= min * 60
+    if hrs > 0:
+        return "%dh%dm%ds" % (hrs, min, sec)
+    elif min > 0:
+        return "%dm%ds" % (min, sec)
+    else:
+        return "%ds" % (sec)
+
+class BBTimer(progressbar.Timer):
+    format_time = staticmethod(bb_elapsed)
+
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
         self.id = msg
@@ -250,16 +265,7 @@ class TerminalFilter(object):
         self._footer_lines = None
 
     def elapsed(self, sec):
-        hrs = int(sec / 3600.0)
-        sec -= hrs * 3600
-        min = int(sec / 60.0)
-        sec -= min * 60
-        if hrs > 0:
-            return "%dh%dm%ds" % (hrs, min, sec)
-        elif min > 0:
-            return "%dm%ds" % (min, sec)
-        else:
-            return "%ds" % (sec)
+        return bb_elapsed(sec)
 
     def keepAlive(self, t):
         if not self.cuu:
@@ -354,7 +360,7 @@ class TerminalFilter(object):
                 msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks)
             maxtask = self.helper.tasknumber_total
             if not self.main_progress or self.main_progress.maxval != maxtask:
-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', BBTimer(format='Elapsed: %s')]
                 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle)
                 self.main_progress.fd = self._footer_buf
                 self.main_progress.start(False)
Signature · 1 line
2.53.0
author
#4 lore raw

Any chance to get this be merged?

#5 lore raw
In reply to WXbet
Quoted 7 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of WXbet via lists.openembedded.org
Sent: den 19 augusti 2026 11:33
To: [email protected]
Cc: WXbet <[email protected]>
Subject: [bitbake-devel] [PATCH] knotty: show elapsed time on the task progress bar

Quoted 8 lines

The progress bar for the overall build shows a percentage and a bar but no elapsed time, even though the individual running-task lines below it each show one.

Add a Timer widget to the bar. The time formatting in TerminalFilter.elapsed() is hoisted to a module-level bb_elapsed() helper and reused by a small progressbar.Timer subclass, so the bar prints the same "%dh%dm%ds" style as the rest of the UI.

On the other hand, the progress bars that are shown during the initial phase before the build tasks starts all use Progressbar's own Timer widget. I think it makes more sense to just use progressbar.Timer() rather than BBTimer().

Quoted 60 lines
---
 lib/bb/ui/knotty.py | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
lib/bb/ui/knotty.py +17 -12
index 15025e8dd..343045881 100644
@@ -37,6 +37,21 @@ featureSet = [bb.cooker.CookerFeatures.SEND_SANITYEVENTS, bb.cooker.CookerFeatur
 logger = logging.getLogger("BitBake")
 interactive = sys.stdout.isatty()
 
+def bb_elapsed(sec):
+    hrs = int(sec / 3600.0)
+    sec -= hrs * 3600
+    min = int(sec / 60.0)
+    sec -= min * 60
+    if hrs > 0:
+        return "%dh%dm%ds" % (hrs, min, sec)
+    elif min > 0:
+        return "%dm%ds" % (min, sec)
+    else:
+        return "%ds" % (sec)
+
+class BBTimer(progressbar.Timer):
+    format_time = staticmethod(bb_elapsed)
+
 class BBProgress(progressbar.ProgressBar):
     def __init__(self, msg, maxval, widgets=None, extrapos=-1, resize_handler=None):
         self.id = msg
@@ -250,16 +265,7 @@ class TerminalFilter(object):
         self._footer_lines = None
 
     def elapsed(self, sec):
-        hrs = int(sec / 3600.0)
-        sec -= hrs * 3600
-        min = int(sec / 60.0)
-        sec -= min * 60
-        if hrs > 0:
-            return "%dh%dm%ds" % (hrs, min, sec)
-        elif min > 0:
-            return "%dm%ds" % (min, sec)
-        else:
-            return "%ds" % (sec)
+        return bb_elapsed(sec)
 
     def keepAlive(self, t):
         if not self.cuu:
@@ -354,7 +360,7 @@ class TerminalFilter(object):
                 msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks)
             maxtask = self.helper.tasknumber_total
             if not self.main_progress or self.main_progress.maxval != maxtask:
-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', BBTimer(format='Elapsed: %s')]
                 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle)
                 self.main_progress.fd = self._footer_buf
                 self.main_progress.start(False)
--
Quoted 1 line

2.53.0

//Peter

author
#6 lore raw
Quoted 5 lines · Peter Kjellerstedt

On the other hand, the progress bars that are shown during the initial phase before the build tasks starts all use Progressbar's own Timer widget. I think it makes more sense to just use progressbar.Timer() rather than BBTimer().

The formatting is deliberate. The running-task lines right below the bar print their time through TerminalFilter.elapsed() , e.g. 16m34s. With progressbar.Timer the bar reads 0:16:34 , so the same screen would show two different time formats. The parsing-phase bars are gone by the time the task bar appears, so they never compete with it.

Timer.format_time is a staticmethod and Timer defines __slots__ , so it cannot be replaced per instance, hence the small subclass.

If you prefer consistency with progressbar's own format, this one-liner does it instead and I am happy to send it as v2:

-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.Timer(format='Elapsed: %s')]

#7 lore raw
Quoted 12 lines

-----Original Message-----
From: [email protected] <[email protected]> On Behalf Of WXbet via lists.openembedded.org
Sent: den 26 augusti 2026 17:16
To: [email protected]
Subject: Re: [bitbake-devel] [PATCH] knotty: show elapsed time on the task progress bar

Quoted 4 lines · Peter Kjellerstedt

On the other hand, the progress bars that are shown during the initial phase before the build tasks starts all use Progressbar's own Timer widget. I think it makes more sense to just use progressbar.Timer() rather than BBTimer().

Quoted 4 lines

The formatting is deliberate. The running-task lines right below the bar print their time through TerminalFilter.elapsed(), e.g. 16m34s. With progressbar.Timer the bar reads 0:16:34, so the same screen would show two different time formats.

True, but the times that are displayed through elapsed() are shown as part of the label for each task. There it makes sense to keep them short, and since most tasks run in the matter of seconds or a few minutes, always displaying the time with hours is excessive.

The total build time on the other hand is shown as part of the progress bar to the right, and can easily reach hours.

Quoted 2 lines

The parsing-phase bars are gone by
the time the task bar appears, so they never compete with it.

Not entirely true. This is what it looks like when I build, with the default Timer() enabled in the overall tasks progress bar:

Initialising tasks: 100% |######################################################| Time: 0:00:07 Checking sstate mirror object availability (475): 100% |########################| Time: 0:00:00 Sstate summary: Wanted 475 Local 0 Mirrors 0 Missed 475 Current 10917 (0% match, 95% complete)
NOTE: Executing Tasks
1 running tasks (21335 of 21694) 98% |############################## | Elapsed Time: 0:00:00

So using Progressbar's formatting matches the already existing progress bars.

Quoted 9 lines

Timer.format_time is a staticmethod and Timer defines __slots__, so it cannot be replaced per instance, hence the small subclass.

If you prefer consistency with progressbar's own format, this one-liner does it instead and I am happy to send it as v2:

-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.Timer(format='Elapsed: %s')]

No need for as special format, the default is "Elapsed Time: %s" and I think it makes sense to keep the "Time" part:

                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.Timer()]

That said, I like having the total time in the progress bar. I always run my builds as time bitbake ... so that I have the total build time afterwards, but having the currently elapsed time is very nice as well.

//Peter

#9 lore raw

PATCH v2 1/1 knotty: show elapsed time on the task progress bar

In reply to WXbet

The progress bar for the overall build shows a percentage and a bar but no elapsed time, although a build easily runs for hours.

Add progressbar's Timer widget to it, which prints the same way as the bars of the initialisation phase that stay on screen above it.

---
 lib/bb/ui/knotty.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/bb/ui/knotty.py +1 -1
index 15025e8dd..1a3198b5c 100644
@@ -354,7 +354,7 @@ class TerminalFilter(object):
                 msg = "Currently %2s running tasks (%s)" % (len(activetasks), cur_tasks)
             maxtask = self.helper.tasknumber_total
             if not self.main_progress or self.main_progress.maxval != maxtask:
-                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar()]
+                widgets = [' ', progressbar.Percentage(), ' ', progressbar.Bar(), ' ', progressbar.Timer()]
                 self.main_progress = BBProgress("Running tasks", maxtask, widgets=widgets, resize_handler=self.sigwinch_handle)
                 self.main_progress.fd = self._footer_buf
                 self.main_progress.start(False)