worker: push data when clients can receive them

Enterprise / Virtualization / SPICE - Frediano Ziglio [redhat.com] - 3 February 2016 10:02 UTC

During every iteration of the main worker loop, outgoing data was pushed to the client. However, there was no guarantee that the loop would be woken up in every situation. So there were some conditions where the loop would stop iterating until a new event was sent.

Currently, the events that can wake up the main worker loop include:- data from dispatcher (including wakeups from the guest)- data from clients- timeouts on a stream- other timeouts- polling

This patch adds a new wakeup event: when we have items that are queued to be sent to a client, we set up a watch event for writing data to the client. If no items are waiting to be sent, this watch will be disabled. This allows us to remove the explicit push from the main worker loop.

This has some advantages:
- it could lower latency as we don't have to wait for a polling timeout. From my experiments using a tight loop (so not really the ideal condition to see the improvements) the total time was reduced by 2-3%)- helps reduce the possibility of hanging loops
- avoids having to scan all clients to detect which one can accept data.

5c460de worker: push data when clients can receive them
server/red-channel.c | 39 ++++++++++++++++++---------------------
server/red-worker.c | 13 -------------
2 files changed, 18 insertions(+), 34 deletions(-)

Upstream: cgit.freedesktop.org


  • Share