[client/idd] input: reduce network latency

Route input through a dedicated high-priority stream, send pointer
motion as cumulative datagrams, and recover suspected loss reliably.

Reduce downstream input queuing with age-aware coalescing and input
thread scheduling.
This commit is contained in:
Geoffrey McRae
2026-10-08 20:34:04 +11:00
parent e30afaca2d
commit 1af2f13440
17 changed files with 3359 additions and 759 deletions

View File

@@ -32,14 +32,16 @@
class CInputPipeServer : public IInputSink, private IPipeEndpointHandler
{
private:
static constexpr size_t QUEUE_LENGTH = 128;
static constexpr size_t MOTION_COALESCE_THRESHOLD = QUEUE_LENGTH / 2;
static constexpr DWORD STATISTICS_INTERVAL_MS = 5000;
static constexpr size_t QUEUE_LENGTH = 128;
static constexpr size_t MOTION_EMERGENCY_DEPTH = 8;
static constexpr DWORD MOTION_AGE_BUDGET_MS = 1;
static constexpr DWORD STATISTICS_INTERVAL_MS = 5000;
struct QueueItem
{
KVMFRInputPayload payload;
uint64_t state;
int64_t enqueueTicks;
LGInputPipeMessageType type;
bool pureMotion;
};
@@ -84,15 +86,20 @@ private:
uint64_t m_statResyncDiscarded = 0;
size_t m_statQueueHighWater = 0;
uint64_t m_statSent = 0;
uint64_t m_statStale = 0;
uint64_t m_statWriteFailed = 0;
uint64_t m_statSlowWrites = 0;
int64_t m_statWriteTicks = 0;
int64_t m_statMaxWriteTicks = 0;
ULONGLONG m_lastStatistics = 0;
uint64_t m_statSent = 0;
uint64_t m_statStale = 0;
uint64_t m_statWriteFailed = 0;
uint64_t m_statSlowWrites = 0;
int64_t m_statWriteTicks = 0;
int64_t m_statMaxWriteTicks = 0;
int64_t m_motionBudgetTicks = 0;
ULONGLONG m_lastStatistics = 0;
LARGE_INTEGER m_performanceFrequency = {};
bool MotionBudgetExceededLocked() const;
QueueItem& GetQueueItemLocked(size_t position);
void RemoveQueueItemLocked(size_t position);
bool CompactQueuedMotionLocked();
bool QueueLocked(LGInputPipeMessageType type,
const KVMFRInputPayload& payload, bool pureMotion);
bool QueueRawLocked(LGInputPipeMessageType type,