vnc: throttle screen updates.
PATCH 3/3 vnc: throttle screen updates.
Hi,
This patch makes the vnc server code skip screen refreshes in case there is data in the output buffer. This reduces the refresh rate to throttle the bandwidth needed in case the network link is saturated.
cheers,
Gerd
Quoted 1 line
From
e1a20de776afe0d108fa94b2170f6d5690f9a24cMon Sep 17 00:00:00 2001
From: Gerd Hoffmann <[email protected]>
Date: Mon, 16 Mar 2009 21:37:48 +0100
Subject: [PATCH 3/3] vnc: throttle screen updates.
This patch makes the vnc server code skip screen refreshes in case there is data in the output buffer. This reduces the refresh rate to throttle the bandwidth needed in case the network link is saturated.
--- vnc.c | 11 ++++++++++- vnc.h | 1 + 2 files changed, 11 insertions(+), 1 deletions(-)
vnc.c +10 -1
@@ -649,6 +649,7 @@ static void send_framebuffer_update(VncState *vs, int x, int y, int w, int h)static void vnc_copy (VncState *vs,int src_x,int src_y,int dst_x,int dst_y,int w,int h) { + vs->force_update =1 ;vnc_update_client (vs);vnc_write_u8 (vs,0 );/* msg id */
@@ -704,6 +705,12 @@ static void vnc_update_client(void *opaque)vga_hw_update (); +if (vs->output.offset && !vs->audio_cap && !vs->force_update) { +/* kernel send buffers are full -> drop frames to throttle */ +qemu_mod_timer (vs->timer,qemu_get_clock (rt_clock) +VNC_REFRESH_INTERVAL ); +return ; + } +/* * Walk through the guest dirty map. * Check and copy modified bits from guest to server surface.
@@ -737,7 +744,7 @@ static void vnc_update_client(void *opaque) server_row +=ds_get_linesize (vs->ds); } -if (!has_dirty && !vs->audio_cap) { +if (!has_dirty && !vs->audio_cap && !vs->force_update) {qemu_mod_timer (vs->timer,qemu_get_clock (rt_clock) +VNC_REFRESH_INTERVAL );return ; }
@@ -781,6 +788,7 @@ static void vnc_update_client(void *opaque) vs->output.buffer[saved_offset] = (n_rectangles >>8 ) &0xFF ; vs->output.buffer[saved_offset +1 ] = n_rectangles &0xFF ;vnc_flush (vs); + vs->force_update =0 ; }
@@ -1398,6 +1406,7 @@ static void framebuffer_update_request(VncState *vs, int incremental,int i; vs->need_update =1 ; + vs->force_update =1 ;if (!incremental) {for (i =0 ; i < h; i++) { vnc_set_bits(vs->guest.dirty[y_position + i],
vnc.h +1 -0
@@ -121,6 +121,7 @@ struct VncStateVncDisplay *vd;int need_update; +int force_update;uint32_t features;int absolute;int last_x;
Signature · 1 line
1.6.1.3
Quoted 6 lines · Gerd Hoffmann
Hi,
This patch makes the vnc server code skip screen refreshes in case there is data in the output buffer. This reduces the refresh rate to throttle the bandwidth needed in case the network link is saturated.
I like the idea behind this patch, but I would make force_update an unsigned integer instead of a boolean, incrementing it every time we get a framebuffer_update_request and decrementing it every time we send a reply.
Secondly we could even move vga_hw_update after:
if (vs->output.offset && !vs->audio_cap && !vs->force_update)
Quoted 4 lines · Stefano Stabellini
I like the idea behind this patch, but I would make
force_updatean unsigned integer instead of a boolean, incrementing it every time we get aframebuffer_update_requestand decrementing it every time we send a reply.
Point being?
Note that we can satisfy multiple update requests in one reply. Also note that vnc_copy() sets force_update too.
Quoted 3 lines
Secondly we could even move
vga_hw_updateafter:if (
vs->output.offset&& !vs->audio_cap && !vs->force_update)
Agreed.
cheers,
Gerd
Quoted 3 lines · Gerd Hoffmann
Point being?
Note that we can satisfy multiple update requests in one reply. Also note thatvnc_copy()setsforce_updatetoo.
right, not so useful then. I drop the suggestion.