From eb9719cc8b9a308654ccd2c3bce8a7047b6e2a1a Mon Sep 17 00:00:00 2001 From: Nicolas James Date: Wed, 8 Apr 2026 00:56:40 +1000 Subject: Refactor storing submissions into FrameSpan class, reduce AntiLag thread contention --- src/frame_span.hh | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 src/frame_span.hh (limited to 'src/frame_span.hh') diff --git a/src/frame_span.hh b/src/frame_span.hh new file mode 100644 index 0000000..5220702 --- /dev/null +++ b/src/frame_span.hh @@ -0,0 +1,37 @@ +#ifndef FRAME_SPAN_HH_ +#define FRAME_SPAN_HH_ + +#include "timestamp_pool.hh" + +namespace low_latency { + +// A class which contains timestamps that represent a Queue's contribution to +// a frame. It reduces the (possibly) huge amount of TimestampPool::Handle's +// that a queue needs to keep track of. It only keeps at max two - the first +// head handle and the tail handle, which is allowed to be null in the case of +// only a single submission for that queue. +class FrameSpan { + public: + const std::shared_ptr head_handle; + std::shared_ptr tail_handle; + + public: + FrameSpan(std::shared_ptr handle); + FrameSpan(const FrameSpan&) = delete; + FrameSpan(FrameSpan&&) = delete; + FrameSpan operator=(const FrameSpan&) = delete; + FrameSpan operator=(FrameSpan&&) = delete; + ~FrameSpan(); + + public: + // Update the framespan's tail to include this timestamp. + void update(std::shared_ptr handle); + + public: + // Wait for for GPU work to complete. + void await_completed() const; +}; + +} // namespace low_latency + +#endif \ No newline at end of file -- cgit v1.2.3