diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2023-08-08 16:50:54 +0800 |
---|---|---|
committer | Martin Jansa <martin.jansa@gmail.com> | 2023-12-21 14:03:53 +0100 |
commit | ff2b69d18bda1321ca1e61ab38fc82cc926d9545 (patch) | |
tree | fd2a212e14621544693158c48cc71c51f74aa9c0 | |
parent | f31c94c2833f232691a439124f5f57a79cd38d60 (diff) | |
download | bitbake-contrib-ff2b69d18bda1321ca1e61ab38fc82cc926d9545.tar.gz |
runqueue.py: fix PSI check logic
The current calculation is not correct because if tdiff is less than
1.0, it's not taken into consideration when calculating the current
pressure.
Also, make it clear that the 1.0s is the psi accumulation cycle,
which might be changed in the future. We have this cycle because it
could largely avoid the 0 result issue, that is, if the interval
between checks are too small, the result might be 0. With this
accumulation logic, which has been there but let's make it clear,
this 0 result problem could be mitigated.
Signed-off-by: Chen Qi <Qi.Chen@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r-- | lib/bb/runqueue.py | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/bb/runqueue.py b/lib/bb/runqueue.py index 1b8a367a7..41f5811ea 100644 --- a/lib/bb/runqueue.py +++ b/lib/bb/runqueue.py @@ -200,7 +200,8 @@ class RunQueueScheduler(object): curr_memory_pressure = memory_pressure_fds.readline().split()[4].split("=")[1] now = time.time() tdiff = now - self.prev_pressure_time - if tdiff > 1.0: + psi_accumulation_interval = 1.0 + if tdiff > psi_accumulation_interval: 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 @@ -209,9 +210,9 @@ class RunQueueScheduler(object): 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 + 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 pressure_state = (exceeds_cpu_pressure, exceeds_io_pressure, exceeds_memory_pressure) if hasattr(self, "pressure_state") and pressure_state != self.pressure_state: bb.note("Pressure status changed to CPU: %s, IO: %s, Mem: %s" % pressure_state) |