Log gpu usage (#21404)

* Log gpu usage

* 100 total

* bump cereal

Co-authored-by: Adeeb Shihadeh <adeebshihadeh@gmail.com>
old-commit-hash: ad7f0207ac9c587c2e1740c61bddad5fbba11296
This commit is contained in:
Willem Melching
2021-06-29 22:55:18 +02:00
committed by GitHub
parent b433129fd6
commit 30fff7fead
6 changed files with 19 additions and 1 deletions

2
cereal

Submodule cereal updated: 232e28c2bb...e1793a1854

View File

@@ -113,3 +113,7 @@ class HardwareBase:
@abstractmethod
def set_power_save(self, enabled):
pass
@abstractmethod
def get_gpu_usage_percent(self):
pass

View File

@@ -377,3 +377,6 @@ class Android(HardwareBase):
def set_power_save(self, enabled):
pass
def get_gpu_usage_percent(self):
return 0

View File

@@ -85,3 +85,6 @@ class Pc(HardwareBase):
def set_power_save(self, enabled):
pass
def get_gpu_usage_percent(self):
return 0

View File

@@ -262,3 +262,10 @@ class Tici(HardwareBase):
# TODO: fix permissions with udev
val = "0" if enabled else "1"
os.system(f"sudo su -c 'echo {val} > /sys/devices/system/cpu/cpu{i}/online'")
def get_gpu_usage_percent(self):
try:
used, total = open('/sys/class/kgsl/kgsl-3d0/gpubusy').read().strip().split()
return 100.0 * int(used) / int(total)
except Exception:
return 0

View File

@@ -265,6 +265,7 @@ def thermald_thread():
msg.deviceState.freeSpacePercent = get_available_percent(default=100.0)
msg.deviceState.memoryUsagePercent = int(round(psutil.virtual_memory().percent))
msg.deviceState.cpuUsagePercent = int(round(psutil.cpu_percent()))
msg.deviceState.gpuUsagePercent = int(round(HARDWARE.get_gpu_usage_percent()))
msg.deviceState.networkType = network_type
msg.deviceState.networkStrength = network_strength
if network_info is not None: