From: Ola x Nilsson <ola.x.nilsson@axis.com>
To: <randy.macleod@windriver.com>
Cc: <Qi.Chen@windriver.com>,
Randy MacLeod via lists.openembedded.org
<randy.macleod=windriver.com@lists.openembedded.org>,
<bitbake-devel@lists.openembedded.org>
Subject: Re: [bitbake-devel][PATCH V2] runqueue.py: fix PSI check logic
Date: Thu, 25 May 2023 10:17:48 +0200 [thread overview]
Message-ID: <jwqilcg4ydl.fsf@axis.com> (raw)
In-Reply-To: <a963a98b-0420-5785-b393-306ebbf6f230@windriver.com>
On Tue, May 23 2023, Randy MacLeod via lists.openembedded.org wrote:
> On 2023-05-22 22:09, Qi.Chen@windriver.com wrote:
>> From: Chen Qi<Qi.Chen@windriver.com>
>>
>> The current logic is not correct because if the time interval
>> between the current check and the last check is very small, the PSI
>> checker is not likely to block things even if the system is heavy
>> loaded.
>>
>> It's not good to calculate the value too often. So we change to a 1s
>> check. As a build will usually take at least minutes, using the 1s value
>> seems reasonable.
>
> I don't have time to check today but I'm not convinced that this is true.
>
> I suspect that in the typical case, it would be okay but there will be
> workloads (perhaps rare workloads) where you want to check more often.
>
> The 1 second intervals where we no longer launch new work may
> result in a significantly longer build. IIRC, our benchmark was building
> core-image-minimal on a 24 core system without PSI regulation and then
> with it set to 300. I'd look at the elapsed time and the
> buildchart/bootchart:
> scripts/pybootchartgui/README.pybootchart
>
> Ola, have you been able to test this and if not, can you?
>
This patch is identical to the V1 except for the commit message, so I
consider it
Tested-By: Ola Nilsson <ola.x.nilsson@axis.com>
/Ola
> All for today.
>
> ../Randy
>
>
>>
>> Signed-off-by: Chen Qi<Qi.Chen@windriver.com>
>> ---
>> bitbake/lib/bb/runqueue.py | 29 ++++++++++++++---------------
>> 1 file changed, 14 insertions(+), 15 deletions(-)
>>
>> diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
>> index 02f1474540..4d49d25153 100644
>> --- a/bitbake/lib/bb/runqueue.py
>> +++ b/bitbake/lib/bb/runqueue.py
>> @@ -179,6 +179,7 @@ class RunQueueScheduler(object):
>> self.prev_memory_pressure = memory_pressure_fds.readline().split()[4].split("=")[1]
>> self.prev_pressure_time = time.time()
>> self.check_pressure = True
>> + self.psi_exceeded = False
>> except:
>> bb.note("The /proc/pressure files can't be read. Continuing build
> without monitoring pressure")
>> self.check_pressure = False
>> @@ -191,6 +192,10 @@ class RunQueueScheduler(object):
>> BB_PRESSURE_MAX_{CPU|IO|MEMORY} are set, return True if above threshold.
>> """
>> if self.check_pressure:
>> + now = time.time()
>> + tdiff = now - self.prev_pressure_time
>> + if tdiff < 1.0:
>> + return self.psi_exceeded
>> with open("/proc/pressure/cpu") as cpu_pressure_fds, \
>> open("/proc/pressure/io") as io_pressure_fds, \
>> open("/proc/pressure/memory") as memory_pressure_fds:
>> @@ -198,21 +203,15 @@ class RunQueueScheduler(object):
>> curr_cpu_pressure = cpu_pressure_fds.readline().split()[4].split("=")[1]
>> curr_io_pressure = io_pressure_fds.readline().split()[4].split("=")[1]
>> curr_memory_pressure = memory_pressure_fds.readline().split()[4].split("=")[1]
>> - now = time.time()
>> - tdiff = now - self.prev_pressure_time
>> - if tdiff > 1.0:
>> - exceeds_cpu_pressure = self.rq.max_cpu_pressure and
> (float(curr_cpu_pressure) - float(self.prev_cpu_pressure)) / tdiff >
> self.rq.max_cpu_pressure
>> - exceeds_io_pressure = self.rq.max_io_pressure and
> (float(curr_io_pressure) - float(self.prev_io_pressure)) / tdiff >
> self.rq.max_io_pressure
>> - exceeds_memory_pressure = self.rq.max_memory_pressure and
> (float(curr_memory_pressure) - float(self.prev_memory_pressure)) /
> tdiff > self.rq.max_memory_pressure
>> - self.prev_cpu_pressure = curr_cpu_pressure
>> - self.prev_io_pressure = curr_io_pressure
>> - self.prev_memory_pressure = curr_memory_pressure
>> - self.prev_pressure_time = now
>> - else:
>> - exceeds_cpu_pressure = self.rq.max_cpu_pressure and
> (float(curr_cpu_pressure) - float(self.prev_cpu_pressure)) >
> self.rq.max_cpu_pressure
>> - exceeds_io_pressure = self.rq.max_io_pressure and
> (float(curr_io_pressure) - float(self.prev_io_pressure)) >
> self.rq.max_io_pressure
>> - exceeds_memory_pressure = self.rq.max_memory_pressure and
> (float(curr_memory_pressure) - float(self.prev_memory_pressure)) >
> self.rq.max_memory_pressure
>> - return (exceeds_cpu_pressure or exceeds_io_pressure or exceeds_memory_pressure)
>> + exceeds_cpu_pressure = self.rq.max_cpu_pressure and
> (float(curr_cpu_pressure) - float(self.prev_cpu_pressure)) / tdiff >
> self.rq.max_cpu_pressure
>> + exceeds_io_pressure = self.rq.max_io_pressure and
> (float(curr_io_pressure) - float(self.prev_io_pressure)) / tdiff >
> self.rq.max_io_pressure
>> + exceeds_memory_pressure = self.rq.max_memory_pressure and
> (float(curr_memory_pressure) - float(self.prev_memory_pressure)) /
> tdiff > self.rq.max_memory_pressure
>> + self.prev_cpu_pressure = curr_cpu_pressure
>> + self.prev_io_pressure = curr_io_pressure
>> + self.prev_memory_pressure = curr_memory_pressure
>> + self.prev_pressure_time = now
>> + self.psi_exceeded = exceeds_cpu_pressure or exceeds_io_pressure or exceeds_memory_pressure
>> + return self.psi_exceeded
>> return False
>> def next_buildable_task(self):
--
Ola x Nilsson
next prev parent reply other threads:[~2023-05-25 8:19 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-23 2:09 [bitbake-devel][PATCH V2] runqueue.py: fix PSI check logic Qi.Chen
2023-05-23 23:24 ` Randy MacLeod
2023-05-24 2:18 ` ChenQi
2023-05-25 2:09 ` Randy MacLeod
2023-05-25 8:17 ` Ola x Nilsson [this message]
2023-06-08 13:25 ` Randy MacLeod
[not found] ` <1766B1E87F43AC01.3462@lists.openembedded.org>
2023-07-10 23:22 ` Randy MacLeod
2023-07-10 23:33 ` Randy MacLeod
2023-07-11 9:31 ` Richard Purdie
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=jwqilcg4ydl.fsf@axis.com \
--to=ola.x.nilsson@axis.com \
--cc=Qi.Chen@windriver.com \
--cc=bitbake-devel@lists.openembedded.org \
--cc=randy.macleod=windriver.com@lists.openembedded.org \
--cc=randy.macleod@windriver.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.