diff options
author | Chen Qi <Qi.Chen@windriver.com> | 2023-11-10 14:54:35 +0100 |
---|---|---|
committer | Steve Sakoman <steve@sakoman.com> | 2023-12-04 06:03:01 -1000 |
commit | 76889ff0a8938a3d77603d2af176aa9e264df839 (patch) | |
tree | 1a6bf9441742126c6cb8ef52a922965f8e684b50 | |
parent | b5f77e8159ad321f31999af8304f082a2c56b537 (diff) | |
download | bitbake-contrib-76889ff0a8938a3d77603d2af176aa9e264df839.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>
Signed-off-by: Steve Sakoman <steve@sakoman.com>
-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 ab9e3fbe8..830af8eef 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) |