public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
* [PATCH] Have fedabipkgdiff sleep while waiting for abipkgdiff
@ 2023-03-28 19:52 Ben Woodard
  2023-03-31 21:12 ` Dodji Seketeli
  0 siblings, 1 reply; 2+ messages in thread
From: Ben Woodard @ 2023-03-28 19:52 UTC (permalink / raw)
  To: libabigail; +Cc: Ben Woodard

While running tests, I noticed that python was consuming a huge amount
of CPU. Frank ch Eiger fche@redhat.com located the problem and pointed
out that python was continiously polling for abipkgdiff's
completion. For small packages, the time to completion can be less
than a second but some packages can take literally hours to
analyze. Having python spinning in such a tight loop is unnecessary. I
added a small sleep to this loop with a bit of backoff. Vanessa Sochat
helped with examples of how to fix the python code.

     * tools/fedabipkgdiff add sleep while waiting for subprocess
     completion.

Signed-off-by: Ben Woodard <woodard@redhat.com>
---
 tools/fedabipkgdiff | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/tools/fedabipkgdiff b/tools/fedabipkgdiff
index db23d5a3..2867a8d0 100755
--- a/tools/fedabipkgdiff
+++ b/tools/fedabipkgdiff
@@ -20,6 +20,7 @@ import shutil
 import six
 import subprocess
 import sys
+import time
 
 from collections import namedtuple
 from itertools import chain
@@ -1187,9 +1188,14 @@ def abipkgdiff(cmp_half1, cmp_half2):
     # then we get its output.
     #
 
+    sleeptime = 0.2
     while True:
         if proc.poll() != None:
             break
+        time.sleep(sleeptime)
+        # cap the sleep time at 1.6s
+        if sleeptime < 2.0:
+            sleeptime = sleeptime * 2
 
     stdout = ''.join(proc.stdout.readlines())
     stderr = ''.join(proc.stderr.readlines())
-- 
2.31.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2023-03-31 21:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-28 19:52 [PATCH] Have fedabipkgdiff sleep while waiting for abipkgdiff Ben Woodard
2023-03-31 21:12 ` Dodji Seketeli

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).