From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [217.70.183.195]) by sourceware.org (Postfix) with ESMTPS id DED063858D28 for ; Fri, 31 Mar 2023 21:12:12 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DED063858D28 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=seketeli.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=seketeli.org Received: (Authenticated sender: dodji@seketeli.org) by mail.gandi.net (Postfix) with ESMTPSA id 3A23560004; Fri, 31 Mar 2023 21:12:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seketeli.org; s=gm1; t=1680297131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WQAFSnSTubTmdLIOLImSD5xcsvuhLnRXns7jGfWWCCM=; b=Rr7d6TCy0j39YBA8RdFc5gPZqFpMYh9Fscyve0kQ8AjFGPDYG84pRVwAiiZSyuMLS+cRQ/ VzzdMervMHB/2xPOth1Tnq+1i3E1BamEVR57X9XXcCY1ROETrio6uBJlMcVtEG19ETEPk5 KVMEmL9ZETWuBSV53kxZEm0ZE62MC6IBsdAe8MmMEYwcIhiMa8AJOeUGGHm+IQFeV18uiQ +9gASgZ1bLpnP7xaJwyUUQ0OwCxYfJaqqSzL8pOlfl2UUC6xgun4bS3wPoR11rKuN4Hj+R Oo/99Wprlu3oiyyVgtXeQP2cA6tkoD+c7AWuPsTmFuxbViNezoSZd2W0sxOI4A== Received: by localhost (Postfix, from userid 1000) id 9BDE5581C79; Fri, 31 Mar 2023 23:12:10 +0200 (CEST) From: Dodji Seketeli To: Ben Woodard via Libabigail Cc: Ben Woodard Subject: Re: [PATCH] Have fedabipkgdiff sleep while waiting for abipkgdiff Organization: Me, myself and I References: <20230328195228.701948-1-woodard@redhat.com> X-Operating-System: Fedora 38 X-URL: http://www.seketeli.net/~dodji Date: Fri, 31 Mar 2023 23:12:10 +0200 In-Reply-To: <20230328195228.701948-1-woodard@redhat.com> (Ben Woodard via Libabigail's message of "Tue, 28 Mar 2023 12:52:28 -0700") Message-ID: <877cuwmxqt.fsf@seketeli.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,JMQ_SPF_NEUTRAL,RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hello, Ben Woodard via Libabigail a =C3=A9crit: > 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 Please find below the patch that was applied to mainline. Cheers, >From 1174a9f0c428149e21115401c44c648b3aaa2678 Mon Sep 17 00:00:00 2001 From: Ben Woodard 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 Signed-off-by: Dodji Seketeli --- 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 @@ -20,6 +20,7 @@ import shutil import six import subprocess import sys +import time =20 from collections import namedtuple from itertools import chain @@ -1187,9 +1188,14 @@ def abipkgdiff(cmp_half1, cmp_half2): # then we get its output. # =20 + sleeptime =3D 0.2 while True: if proc.poll() !=3D None: break + time.sleep(sleeptime) + # cap the sleep time at 1.6s + if sleeptime < 2.0: + sleeptime =3D sleeptime * 2 =20 stdout =3D ''.join(proc.stdout.readlines()) stderr =3D ''.join(proc.stderr.readlines()) --=20 2.39.2 --=20 Dodji