GNU bug report logs - #50634
[PATCH] progress: Rate limit drawing in the progress-reporter/bar.

Previous Next

Package: guix-patches;

Reported by: Christopher Baines <mail <at> cbaines.net>

Date: Fri, 17 Sep 2021 10:16:02 UTC

Severity: normal

Tags: patch

Done: Christopher Baines <mail <at> cbaines.net>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 50634 in the body.
You can then email your comments to 50634 AT debbugs.gnu.org in the normal way.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to guix-patches <at> gnu.org:
bug#50634; Package guix-patches. (Fri, 17 Sep 2021 10:16:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Christopher Baines <mail <at> cbaines.net>:
New bug report received and forwarded. Copy sent to guix-patches <at> gnu.org. (Fri, 17 Sep 2021 10:16:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: guix-patches <at> gnu.org
Subject: [PATCH] progress: Rate limit drawing in the progress-reporter/bar.
Date: Fri, 17 Sep 2021 11:15:56 +0100
This helps smooth the output in cases where the bar is updated very quickly,
for example in guix weather where it's computing derivations.

* guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
rate-limited procedure.
---
 guix/progress.scm | 26 ++++++++++++++++----------
 1 file changed, 16 insertions(+), 10 deletions(-)

diff --git a/guix/progress.scm b/guix/progress.scm
index 0cbc804ec1..4f8e98edc0 100644
--- a/guix/progress.scm
+++ b/guix/progress.scm
@@ -270,19 +270,25 @@ ABBREVIATION used to shorten FILE for display."
 tasks is performed.  Write PREFIX at the beginning of the line."
   (define done 0)
 
+  (define (draw-bar)
+    (let* ((ratio (* 100. (/ done total))))
+      (erase-current-line port)
+      (if (string-null? prefix)
+          (display (progress-bar ratio (current-terminal-columns)) port)
+          (let ((width (- (current-terminal-columns)
+                          (string-length prefix) 3)))
+            (display prefix port)
+            (display "  " port)
+            (display (progress-bar ratio width) port)))
+      (force-output port)))
+
+  (define draw-bar/rate-limited
+    (rate-limited draw-bar %progress-interval))
+
   (define (report-progress)
     (set! done (+ 1 done))
     (unless (> done total)
-      (let* ((ratio (* 100. (/ done total))))
-        (erase-current-line port)
-        (if (string-null? prefix)
-            (display (progress-bar ratio (current-terminal-columns)) port)
-            (let ((width (- (current-terminal-columns)
-                            (string-length prefix) 3)))
-              (display prefix port)
-              (display "  " port)
-              (display (progress-bar ratio width) port)))
-        (force-output port))))
+      (draw-bar/rate-limited)))
 
   (progress-reporter
    (start (lambda ()
-- 
2.33.0





Information forwarded to guix-patches <at> gnu.org:
bug#50634; Package guix-patches. (Thu, 30 Sep 2021 21:06:02 GMT) Full text and rfc822 format available.

Message #8 received at 50634 <at> debbugs.gnu.org (full text, mbox):

From: Ludovic Courtès <ludo <at> gnu.org>
To: Christopher Baines <mail <at> cbaines.net>
Cc: 50634 <at> debbugs.gnu.org
Subject: Re: bug#50634: [PATCH] progress: Rate limit drawing in the
 progress-reporter/bar.
Date: Thu, 30 Sep 2021 23:05:10 +0200
Hi Christopher,

Christopher Baines <mail <at> cbaines.net> skribis:

> This helps smooth the output in cases where the bar is updated very quickly,
> for example in guix weather where it's computing derivations.
>
> * guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
> rate-limited procedure.

I hit that problem quite frequently lately in shell-mode so I’m grateful
you fixed it.  Go for it!

Thanks,
Ludo’.




Reply sent to Christopher Baines <mail <at> cbaines.net>:
You have taken responsibility. (Sun, 12 Dec 2021 15:25:02 GMT) Full text and rfc822 format available.

Notification sent to Christopher Baines <mail <at> cbaines.net>:
bug acknowledged by developer. (Sun, 12 Dec 2021 15:25:02 GMT) Full text and rfc822 format available.

Message #13 received at 50634-done <at> debbugs.gnu.org (full text, mbox):

From: Christopher Baines <mail <at> cbaines.net>
To: Ludovic Courtès <ludo <at> gnu.org>
Cc: 50634-done <at> debbugs.gnu.org
Subject: Re: bug#50634: [PATCH] progress: Rate limit drawing in the
 progress-reporter/bar.
Date: Sun, 12 Dec 2021 15:23:32 +0000
[Message part 1 (text/plain, inline)]
Ludovic Courtès <ludo <at> gnu.org> writes:

> Hi Christopher,
>
> Christopher Baines <mail <at> cbaines.net> skribis:
>
>> This helps smooth the output in cases where the bar is updated very quickly,
>> for example in guix weather where it's computing derivations.
>>
>> * guix/progress.scm (progress-reporter/bar): Wrap the drawing code with the
>> rate-limited procedure.
>
> I hit that problem quite frequently lately in shell-mode so I’m grateful
> you fixed it.  Go for it!

I seemingly forgot about this, but I've now pushed this patch as
604880ae22e1a7662acb1d3f282242470de0cd03.

Thanks,

Chris
[signature.asc (application/pgp-signature, inline)]

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Mon, 10 Jan 2022 12:24:04 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 100 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.