qcwdfserial: fix latency small chunk reads regression after QUD-1837 ReadIntervalTimeout#65
Conversation
| { | ||
| // If useReadInterval is true but data is already buffered, | ||
| // cancel any pending inter-byte timer before draining: the | ||
| // TIMEOUT_EVENT DPC may still fire if it was already queued, |
There was a problem hiding this comment.
Update comment to
// If useReadInterval is true but data is already buffered,
// cancel any pending inter-byte timer before draining.
// KeCancelTimer returns FALSE if the DPC is already queued;
// in that case ReadTimeoutDpc will fire after KeClearEvent and
// set ReadRequestTimeoutEvent again. READ_THREAD_REQUEST_TIMEOUT_EVENT
// will then find the ring buffer empty (drained below) and complete
// any pending TimeoutReadQueue request with STATUS_TIMEOUT / 0 bytes.
// This is correct RI semantics: the inter-byte gap elapsed and no
// data was available for that request (it was consumed by ReadQueue).
There was a problem hiding this comment.
Comment updated
| { | ||
| status = WdfIoQueueRetrieveNextRequest(pDevContext->ReadQueue, &request); | ||
| } | ||
| // When bypassing the RI timer due to pre-buffered data, we must NOT |
There was a problem hiding this comment.
Fix else block indentation
There was a problem hiding this comment.
Indentation fixed
…t change Fix a latency regression on small chunk reads introduced by "ReadIntervalTimeout inter-byte gap semantics [QUD-1837]". Keep QUD-1837 ReadIntervalTimeout behavior intact by preventing immediate bypass delivery when a request is already pending in TimeoutReadQueue and no new request exists in ReadQueue. In READ_THREAD_REQUEST_ARRIVE_EVENT (ring-buffer path): - preserve timer-based completion for pending TimeoutReadQueue requests - allow immediate bypass only when serving new ReadQueue requests Signed-off-by: Cristian Manca <Cristian.Manca@telit.com>
8886a5d to
779b381
Compare
Summary
This PR fixes a latency regression introduced by commit
9e60a01974f7bd802c5e6660c6c12812e4d819fc(
fix(wdfserial): implement ReadIntervalTimeout inter-byte gap semantics [QUD-1837]).The regression is most visible with small read sizes (especially 1-byte reads): data already present in the ring buffer could still follow the timer-based path, adding unnecessary delay and reducing throughput.
Root cause
With
ReadIntervalTimeoutenabled, the read path could wait on the inter-byte timer even when bytes were already buffered, effectively serializing delivery and increasing per-read latency.Code-level changes
In
src/windows/wdfserial/QCRD.c, insideQCRD_ReadRequestHandlerThread(READ_THREAD_REQUEST_ARRIVE_EVENTpath):if (useReadInterval && QCUTIL_RingBufferBytesUsed(rxBuffer) == 0)TimeoutReadQueueandReadQueueis empty:REQUEST_TIMEOUT_EVENT.KeCancelTimer(&pDevContext->ReadTimer);KeClearEvent(&pDevContext->ReadRequestTimeoutEvent);ReadQueue(not drained fromTimeoutReadQueue) so timeout-queued requests remain timer-governed.Impact