Improving sending queue sleepto() accuracy #678
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
The sleeping time for the SRT sending queue is 10 ms, and it is discrete.
That means, if a thread wants to sleep for 5 ms, it will sleep for 10 ms.
If a thread wants to sleep for 15 ms, it will sleep for 10 ms, and then again for another 10 ms, that will make a total sleep time of 20 ms.
This behavior is incorrect and unnecessary.
Fixes #673.
TODO
Accuracy of the new sleepto()
sleepto
function accuracysleepto
function accuracysleepto
function accuracyAccuracy on Windows
CreateWaitableTimer
Live mode sending accuracy
File mode sending accuracy
Do we need a maximum sleeping time of 10 ms?
In pseudocode, the
sleepto
function works like this:CTimer::sleepto(nexttime)
waits on a CVm_TickCond
.CTimer::tick()
functionThe function
CTimer::tick()
signals this CV, and it will break the wait to force time checking. Thetick()
function is called from the receiving thread inCRcvQueue::worker_RetrieveUnit()
before every operation of reading data from the socket. This is probably wrong, but requires further review.CTimer::interrupt()
functionIn case the thread has to be forced break, there is another function
CTimer::interrupt()
, that changes them_ullSchedTime
to he current time and callstick()
to break any waits.Conclusion
This means that maximum waiting time of 10 ms is not necessary.
Do we need a minimum allowed sleeping time?
As shown in #637, the
sleepto()
function has certain inaccuracy.A final matrix to be placed here.
CTimer::sleepto()
accuracy (proposed implementation) in CV-based waiting mode. Each column shows the actual sleeping time in microseconds for each platform. Measured using unit testCTimer.SleeptoAccuracy
.