From 3a5391dd65152cf7fabf0f593239f27a044d655c Mon Sep 17 00:00:00 2001 From: Filip Leonarski Date: Wed, 18 Nov 2026 10:20:23 +0100 Subject: [PATCH] FPGAImagePuller: a module behind another card waits as long as the slots hold A module was given up for a frame once ANY card was MissingAfterFrames (52) frames further on. The cards run on their own, so a card a little behind lost whole modules from every image: on the mock, 9M on 2 and 4 cards not blocking, the cards drift 50-500 frames apart (each mock card is two CPU threads; none of them ever waited for host buffers, so the drift is the cards' own speed, not the host) and the efficiency was 0.44-0.61. Now a module is missing when its OWN card is MissingAfterFrames further on, as the device itself counts, and behind another card only once that card is max_slots ahead - past that, its images would be dropped for want of a slot anyway. A dead card is still noticed, after max_slots frames. Mock, 9M, 1500 images, not blocking: 2 cards 0.905 (drift up to ~120), 4 cards with 512 slots 0.978 (drift ~380), 4 cards with 128 slots 0.487 (drift ~500, now whole images dropped for want of a slot rather than modules missing). Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01UqXYdHHZ4cogS1mrGUtfN7 --- receiver/FPGAImagePuller.cpp | 3 ++- receiver/FPGAImagePuller.h | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/receiver/FPGAImagePuller.cpp b/receiver/FPGAImagePuller.cpp index 26eacc4c0..5d0d884a4 100644 --- a/receiver/FPGAImagePuller.cpp +++ b/receiver/FPGAImagePuller.cpp @@ -147,7 +147,8 @@ void FPGAImagePuller::WaitForFrame(uint16_t data_stream, uint16_t module_number, // A frame is complete once the module is two further on, as in JFJochReceiverFPGA if ((static_cast(counters.GetCurrFrameNumber(module_number)) >= frame + 2) || counters.IsAcquisitionFinished() || failed - || (!blocking && (FastestFrame() >= frame + 2 + MissingAfterFrames))) + || (!blocking && (static_cast(counters.GetFastestFrameNumber()) >= frame + 2 + MissingAfterFrames)) + || (!blocking && (FastestFrame() >= frame + 2 + static_cast(max_slots)))) return; std::this_thread::sleep_for(std::chrono::milliseconds(1)); } diff --git a/receiver/FPGAImagePuller.h b/receiver/FPGAImagePuller.h index 844a839f5..d5d90a16e 100644 --- a/receiver/FPGAImagePuller.h +++ b/receiver/FPGAImagePuller.h @@ -24,7 +24,9 @@ class FPGAImagePuller : public ImagePuller { public: static constexpr size_t DefaultSlots = 128; - // A module this far behind the fastest one is taken as missing from that frame, as the device itself does + // A module this far behind the fastest one of its card is taken as missing from that frame, as the device itself + // does. Behind another card it is waited for as long as the slots can hold the images started meanwhile: the + // cards run on their own and one can be ahead, but past max_slots its images would be dropped anyway. static constexpr int64_t MissingAfterFrames = AcquisitionCounters::ThresholdFramesLost + 2; private: struct Slot {