public inbox for libabigail@sourceware.org
 help / color / mirror / Atom feed
From: Dodji Seketeli <dodji@seketeli.org>
To: Ben Woodard via Libabigail <libabigail@sourceware.org>
Cc: Ben Woodard <woodard@redhat.com>
Subject: Re: [PATCH] Have fedabipkgdiff sleep while waiting for abipkgdiff
Date: Fri, 31 Mar 2023 23:12:10 +0200	[thread overview]
Message-ID: <877cuwmxqt.fsf@seketeli.org> (raw)
In-Reply-To: <20230328195228.701948-1-woodard@redhat.com> (Ben Woodard via Libabigail's message of "Tue, 28 Mar 2023 12:52:28 -0700")

Hello,

Ben Woodard via Libabigail <libabigail@sourceware.org> a écrit:

> 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.

Thanks Ben!

I have just slightly edited the ChangeLog to make it comply with the
rules (i.e, adding the name of the changed function).  I have also
updated the copyright year that is outdated.

> Signed-off-by: Ben Woodard <woodard@redhat.com>

Please find below the patch that was applied to mainline.

Cheers,

From 1174a9f0c428149e21115401c44c648b3aaa2678 Mon Sep 17 00:00:00 2001
From: Ben Woodard <woodard@redhat.com>
Date: Tue, 28 Mar 2023 12:52:28 -0700
Subject: [PATCH] Have fedabipkgdiff sleep while waiting for abipkgdiff

While running tests, I noticed that python was consuming a huge amount
of CPU. Frank Eigler 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 (abipkgdiff): add sleep while waiting for
	subprocess completion. Also, update copyright year notice to 2023.

Signed-off-by: Ben Woodard <woodard@redhat.com>
Signed-off-by: Dodji Seketeli <dodji@redhat.com>
---
 tools/fedabipkgdiff | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/fedabipkgdiff b/tools/fedabipkgdiff
index db23d5a3..86bf0048 100755
--- a/tools/fedabipkgdiff
+++ b/tools/fedabipkgdiff
@@ -3,7 +3,7 @@
 # -*- coding: utf-8 -*-
 # -*- Mode: Python
 #
-# Copyright (C) 2013-2016 Red Hat, Inc.
+# Copyright (C) 2013-2023 Red Hat, Inc.
 #
 # Author: Chenxiong Qi
 
@@ -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.39.2


-- 
		Dodji

      reply	other threads:[~2023-03-31 21:12 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-28 19:52 Ben Woodard
2023-03-31 21:12 ` Dodji Seketeli [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=877cuwmxqt.fsf@seketeli.org \
    --to=dodji@seketeli.org \
    --cc=libabigail@sourceware.org \
    --cc=woodard@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).