mirror of
https://github.com/infiniteCable2/openpilot.git
synced 2026-09-30 03:23:52 +08:00
Improve realtime performance on NEOS (#2166)
* fix setting core affinity * dmonitoringd doesn't need rt priority * android only gets two cores * model and planner get core 2 * log missed cycle count * neos update * prod image * revert NEOS changes * still need this old-commit-hash: ef21b83937d25b824018ac1d07fa7759ae6f8128
This commit is contained in:
@@ -254,7 +254,7 @@ void can_recv_thread() {
|
||||
useconds_t sleep = remaining / 1000;
|
||||
usleep(sleep);
|
||||
} else {
|
||||
LOGW("missed cycle");
|
||||
LOGW("missed cycles (%d) %lld", (int)-1*remaining/dt, remaining);
|
||||
next_frame_time = cur_time;
|
||||
}
|
||||
|
||||
|
||||
@@ -1589,6 +1589,9 @@ void party(VisionState *s) {
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
set_realtime_priority(51);
|
||||
#ifdef QCOM
|
||||
set_core_affinity(2);
|
||||
#endif
|
||||
|
||||
zsys_handler_set(NULL);
|
||||
signal(SIGINT, (sighandler_t)set_do_exit);
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import gc
|
||||
from cereal import car, log
|
||||
from common.hardware import HARDWARE
|
||||
from common.numpy_fast import clip
|
||||
from common.realtime import sec_since_boot, set_realtime_priority, set_core_affinity, Ratekeeper, DT_CTRL
|
||||
from common.realtime import sec_since_boot, config_rt_process, Priority, Ratekeeper, DT_CTRL
|
||||
from common.profiler import Profiler
|
||||
from common.params import Params, put_nonblocking
|
||||
import cereal.messaging as messaging
|
||||
@@ -43,9 +42,7 @@ EventName = car.CarEvent.EventName
|
||||
|
||||
class Controls:
|
||||
def __init__(self, sm=None, pm=None, can_sock=None):
|
||||
gc.disable()
|
||||
set_realtime_priority(53)
|
||||
set_core_affinity(3)
|
||||
config_rt_process(3, Priority.CTRL_HIGH)
|
||||
|
||||
# Setup sockets
|
||||
self.pm = pm
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
import gc
|
||||
|
||||
from cereal import car
|
||||
from common.params import Params
|
||||
from common.realtime import set_realtime_priority
|
||||
from common.realtime import Priority, config_rt_process
|
||||
from selfdrive.swaglog import cloudlog
|
||||
from selfdrive.controls.lib.planner import Planner
|
||||
from selfdrive.controls.lib.vehicle_model import VehicleModel
|
||||
@@ -12,10 +10,8 @@ import cereal.messaging as messaging
|
||||
|
||||
|
||||
def plannerd_thread(sm=None, pm=None):
|
||||
gc.disable()
|
||||
|
||||
# start the loop
|
||||
set_realtime_priority(52)
|
||||
config_rt_process(2, Priority.CTRL_LOW)
|
||||
|
||||
cloudlog.info("plannerd is waiting for CarParams")
|
||||
CP = car.CarParams.from_bytes(Params().get("CarParams", block=True))
|
||||
|
||||
@@ -7,7 +7,7 @@ import cereal.messaging as messaging
|
||||
from cereal import car
|
||||
from common.numpy_fast import interp
|
||||
from common.params import Params
|
||||
from common.realtime import Ratekeeper, set_realtime_priority
|
||||
from common.realtime import Ratekeeper, Priority, set_realtime_priority
|
||||
from selfdrive.config import RADAR_TO_CAMERA
|
||||
from selfdrive.controls.lib.cluster.fastcluster_py import cluster_points_centroid
|
||||
from selfdrive.controls.lib.radar_helpers import Cluster, Track
|
||||
@@ -174,7 +174,7 @@ class RadarD():
|
||||
|
||||
# fuses camera and radar data for best lead detection
|
||||
def radard_thread(sm=None, pm=None, can_sock=None):
|
||||
set_realtime_priority(52)
|
||||
set_realtime_priority(Priority.CTRL_LOW)
|
||||
|
||||
# wait for stats about the car to come in from controls
|
||||
cloudlog.info("radard is waiting for CarParams")
|
||||
|
||||
@@ -92,7 +92,9 @@ int main(int argc, char **argv) {
|
||||
int err;
|
||||
set_realtime_priority(51);
|
||||
|
||||
#ifdef QCOM2
|
||||
#ifdef QCOM
|
||||
set_core_affinity(2);
|
||||
#elif QCOM2
|
||||
// CPU usage is much lower when pinned to a single big core
|
||||
set_core_affinity(4);
|
||||
#endif
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#!/usr/bin/env python3
|
||||
import gc
|
||||
from cereal import car
|
||||
from common.realtime import set_realtime_priority
|
||||
from common.params import Params
|
||||
import cereal.messaging as messaging
|
||||
from selfdrive.controls.lib.events import Events
|
||||
@@ -10,10 +8,6 @@ from selfdrive.locationd.calibrationd import Calibration
|
||||
|
||||
|
||||
def dmonitoringd_thread(sm=None, pm=None):
|
||||
gc.disable()
|
||||
set_realtime_priority(53)
|
||||
|
||||
# Pub/Sub Sockets
|
||||
if pm is None:
|
||||
pm = messaging.PubMaster(['dMonitoringState'])
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ def cputime_total(ct):
|
||||
|
||||
def print_cpu_usage(first_proc, last_proc):
|
||||
procs = [
|
||||
("selfdrive.controls.controlsd", 66.15),
|
||||
("selfdrive.controls.controlsd", 45.0),
|
||||
("./loggerd", 33.90),
|
||||
("selfdrive.locationd.locationd", 29.5),
|
||||
("selfdrive.controls.plannerd", 11.84),
|
||||
|
||||
Reference in New Issue
Block a user