a8nova's picture
nnopt port: YOLO11n-MLX
56fa795 verified
Raw History Blame Contribute Delete
555 Bytes
// Keep-awake helper for run.py: a user-interactive thread that spins (GIL released, called through ctypes) while
// requests are being served. Without it macOS lowers the CPU cluster clock while the encode thread waits on the
// GPU; MLX then encodes slower, the GPU starves and also clocks down, and per-request latency drifts 5 -> 15 ms.
#include <pthread.h>
#include <pthread/qos.h>
void spin_while(volatile int *flag) {
pthread_set_qos_class_self_np(QOS_CLASS_USER_INTERACTIVE, 0);
while (*flag) {
__asm__ volatile("yield");
}
}