diff --git a/src/aare/gui/threads/prediction_subscriber.py b/src/aare/gui/threads/prediction_subscriber.py index b5234948..42032d82 100644 --- a/src/aare/gui/threads/prediction_subscriber.py +++ b/src/aare/gui/threads/prediction_subscriber.py @@ -30,6 +30,14 @@ class PredictionSubscriber(QThread): self._sock = self._ctx.socket(zmq.SUB) self._sock.setsockopt(zmq.RCVTIMEO, 500) self._sock.setsockopt(zmq.LINGER, 0) + # Cap the backlog the socket may hold. Both must be set before connect() + # to take effect on the pipe. Defaults let the SUB queue grow to 1000 + # messages (20 s of video at 50 Hz) with megabytes more hidden in the + # kernel buffer, which is the backlog _recv_latest would then have to + # throw away every frame. RCVBUF stays well above the ~2.5 MB/s the + # stream actually needs, so it costs no throughput. + self._sock.setsockopt(zmq.RCVHWM, 4) + self._sock.setsockopt(zmq.RCVBUF, 512 * 1024) self._emit_images = True self.running = True