perf: pin dashcamd to cores 0-3 (little cluster)
Previously ran unpinned (affinity mask 0xff) across all 8 cores. When it landed on core 4 (controlsd) or 5 (plannerd/radard) or 7 (modeld), its 70MB/s frame copies and MP4 muxing caused cache/memory-bandwidth contention with the RT-pinned processes. SCHED_FIFO prevented direct preemption but not the cache thrash. OMX offloads actual H.264 work to hardware so the main thread is lightweight — fine on the little cluster. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Binary file not shown.
@@ -38,7 +38,9 @@
|
||||
#include <cstdio>
|
||||
#include <ctime>
|
||||
#include <string>
|
||||
#include <errno.h>
|
||||
#include <signal.h>
|
||||
#include <sched.h>
|
||||
#include <execinfo.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/resource.h>
|
||||
@@ -121,6 +123,20 @@ int main(int argc, char *argv[]) {
|
||||
signal(SIGABRT, crash_handler);
|
||||
setpriority(PRIO_PROCESS, 0, -10);
|
||||
|
||||
// CLEARPILOT: pin to cores 0-3 (little cluster). Avoids cache/memory-bandwidth
|
||||
// contention with the RT-pinned processes on the big cluster:
|
||||
// core 4 = controlsd, core 5 = plannerd/radard, core 7 = modeld.
|
||||
// OMX offloads actual H.264 work to hardware, so the main thread just copies
|
||||
// frames and muxes MP4 — fine on the little cluster.
|
||||
cpu_set_t mask;
|
||||
CPU_ZERO(&mask);
|
||||
for (int i = 0; i < 4; i++) CPU_SET(i, &mask);
|
||||
if (sched_setaffinity(0, sizeof(mask), &mask) != 0) {
|
||||
LOGW("dashcamd: sched_setaffinity failed (%d), continuing unpinned", errno);
|
||||
} else {
|
||||
LOGW("dashcamd: pinned to cores 0-3");
|
||||
}
|
||||
|
||||
// Ensure base output directory exists
|
||||
mkdir(VIDEOS_BASE.c_str(), 0755);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user