diff --git a/selfdrive/navd/SConscript b/selfdrive/navd/SConscript index d1db79506a..c116ef1535 100644 --- a/selfdrive/navd/SConscript +++ b/selfdrive/navd/SConscript @@ -4,7 +4,7 @@ map_env = qt_env.Clone() libs = ['qt_widgets', 'qt_util', 'qmapboxgl', common, messaging, cereal, visionipc, transformations, 'zmq', 'capnp', 'kj', 'm', 'OpenCL', 'ssl', 'crypto', 'pthread', 'json11'] + map_env["LIBS"] if arch == 'larch64': - libs.append('EGL') + libs.append(':libEGL_mesa.so.0') if arch in ['larch64', 'aarch64', 'x86_64']: if arch == 'x86_64': diff --git a/selfdrive/navd/main.cc b/selfdrive/navd/main.cc index f8501bf4a5..5251b046fb 100644 --- a/selfdrive/navd/main.cc +++ b/selfdrive/navd/main.cc @@ -4,14 +4,19 @@ #include #include +#include "common/util.h" #include "selfdrive/ui/qt/util.h" #include "selfdrive/ui/qt/maps/map_helpers.h" #include "selfdrive/navd/map_renderer.h" #include "system/hardware/hw.h" int main(int argc, char *argv[]) { + Hardware::config_cpu_rendering(); + qInstallMessageHandler(swagLogMessageHandler); setpriority(PRIO_PROCESS, 0, -20); + int ret = util::set_core_affinity({0, 1, 2, 3}); + assert(ret == 0); QApplication app(argc, argv); std::signal(SIGINT, sigTermHandler); diff --git a/selfdrive/navd/tests/test_map_renderer.py b/selfdrive/navd/tests/test_map_renderer.py index b9cf42824e..c4c9785cb1 100755 --- a/selfdrive/navd/tests/test_map_renderer.py +++ b/selfdrive/navd/tests/test_map_renderer.py @@ -34,19 +34,12 @@ def gen_llk(location=LOCATION1): class MapBoxInternetDisabledRequestHandler(http.server.BaseHTTPRequestHandler): INTERNET_ACTIVE = True - def setup(self): - if self.INTERNET_ACTIVE: - super().setup() - - def handle(self): - if self.INTERNET_ACTIVE: - super().handle() - - def finish(self): - if self.INTERNET_ACTIVE: - super().finish() - def do_GET(self): + if not self.INTERNET_ACTIVE: + self.send_response(500) + self.end_headers() + return + url = f'https://api.mapbox.com{self.path}' headers = dict(self.headers) @@ -218,12 +211,12 @@ class TestMapRenderer(unittest.TestCase): tol = (nominal / (1+tol)), (nominal * (1+tol)) self.assertTrue(tol[0] < stat < tol[1], f"{stat} not in tolerance {tol}") - assert_stat(_mean, 0.0035) - assert_stat(_median, 0.0034) - assert_stat(_stddev, 0.00093, tol=0.5) + assert_stat(_mean, 0.030) + assert_stat(_median, 0.027) + assert_stat(_stddev, 0.0078) - self.assertLess(_max, 0.2) - self.assertGreater(_min, 0.0010) + self.assertLess(_max, 0.065) + self.assertGreater(_min, 0.015) if __name__ == "__main__": diff --git a/selfdrive/test/process_replay/model_replay_ref_commit b/selfdrive/test/process_replay/model_replay_ref_commit index 1d8befbcab..2785ca71a1 100644 --- a/selfdrive/test/process_replay/model_replay_ref_commit +++ b/selfdrive/test/process_replay/model_replay_ref_commit @@ -1 +1 @@ -eec02217169e6f5d71b8a376368ea96e83b10e4a +ca18755cd1a1bc28c06e85a280d79d7e48a8438c diff --git a/selfdrive/test/test_onroad.py b/selfdrive/test/test_onroad.py index 841c77f142..30632c7cd6 100755 --- a/selfdrive/test/test_onroad.py +++ b/selfdrive/test/test_onroad.py @@ -33,7 +33,7 @@ PROCS = { "./encoderd": 17.0, "./camerad": 14.5, "./locationd": 11.0, - "./mapsd": 2.0, + "./mapsd": 1.5, "selfdrive.controls.plannerd": 16.5, "./_ui": 18.0, "selfdrive.locationd.paramsd": 9.0, @@ -301,7 +301,7 @@ class TestOnroad(unittest.TestCase): self.assertLessEqual(max(mems) - min(mems), 3.0) def test_gpu_usage(self): - self.assertEqual(self.gpu_procs, {"weston", "_ui", "mapsd", "camerad", "selfdrive.modeld.modeld"}) + self.assertEqual(self.gpu_procs, {"weston", "_ui", "camerad", "selfdrive.modeld.modeld"}) def test_camera_processing_time(self): result = "\n" diff --git a/system/hardware/base.h b/system/hardware/base.h index d86b316843..43f5db023d 100644 --- a/system/hardware/base.h +++ b/system/hardware/base.h @@ -34,6 +34,8 @@ public: static bool get_ssh_enabled() { return false; } static void set_ssh_enabled(bool enabled) {} + static void config_cpu_rendering(); + static bool PC() { return false; } static bool TICI() { return false; } static bool AGNOS() { return false; } diff --git a/system/hardware/pc/hardware.h b/system/hardware/pc/hardware.h index 5cd825d61d..63244c5c5d 100644 --- a/system/hardware/pc/hardware.h +++ b/system/hardware/pc/hardware.h @@ -20,4 +20,9 @@ public: snprintf(volume_str, sizeof(volume_str), "%.3f", volume); std::system(("pactl set-sink-volume @DEFAULT_SINK@ " + std::string(volume_str)).c_str()); } + + static void config_cpu_rendering() { + setenv("QT_QPA_PLATFORM", "offscreen", 1); + setenv("__GLX_VENDOR_LIBRARY_NAME", "mesa", 1); + } }; diff --git a/system/hardware/tici/hardware.h b/system/hardware/tici/hardware.h index c1a2dcb169..fe0a20ae58 100644 --- a/system/hardware/tici/hardware.h +++ b/system/hardware/tici/hardware.h @@ -103,4 +103,9 @@ public: static bool get_ssh_enabled() { return Params().getBool("SshEnabled"); } static void set_ssh_enabled(bool enabled) { Params().putBool("SshEnabled", enabled); } + + static void config_cpu_rendering() { + setenv("QT_QPA_PLATFORM", "eglfs", 1); // offscreen doesn't work with EGL/GLES + setenv("LP_NUM_THREADS", "0", 1); // disable threading so we stay on our assigned CPU + } };