Commit 67b4e987 authored by Joel Martin's avatar Joel Martin

Indexed receive queue. Up to 2X speedup in Chrome.

Generally, most servers send hextile updates as single updates
containing many rects. Some servers send hextile updates as many small
framebuffer updates with a few rects each (such as QEMU). This latter
cases revealed that shifting off the beginning of the receive queue
(which happens after each hextile FBU) performs poorly.

This change switches to using an indexed receive queue (instead of
actually shifting off the array). When the receive queue has grown to
a certain size, then it is compacted all at once.

The code is not as clean, but this change results in more than 2X
speedup under Chrome for the pessimal case and 10-20% in firefox.
parent fb007628
...@@ -654,6 +654,18 @@ that.changeCursor = function(pixels, mask, hotx, hoty, w, h) { ...@@ -654,6 +654,18 @@ that.changeCursor = function(pixels, mask, hotx, hoty, w, h) {
return; return;
} }
// Push multi-byte little-endian values
cur.push16le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF );
};
cur.push32le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF,
(num >> 16) & 0xFF,
(num >> 24) & 0xFF );
};
cmap = conf.colourMap; cmap = conf.colourMap;
IHDRsz = 40; IHDRsz = 40;
ANDsz = w * h * 4; ANDsz = w * h * 4;
......
This diff is collapsed.
...@@ -34,68 +34,20 @@ if (!window.$) { ...@@ -34,68 +34,20 @@ if (!window.$) {
* Make arrays quack * Make arrays quack
*/ */
Array.prototype.shift8 = function () {
return this.shift();
};
Array.prototype.push8 = function (num) { Array.prototype.push8 = function (num) {
this.push(num & 0xFF); this.push(num & 0xFF);
}; };
Array.prototype.shift16 = function () {
return (this.shift() << 8) +
(this.shift() );
};
Array.prototype.push16 = function (num) { Array.prototype.push16 = function (num) {
this.push((num >> 8) & 0xFF, this.push((num >> 8) & 0xFF,
(num ) & 0xFF ); (num ) & 0xFF );
}; };
Array.prototype.push16le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF );
};
Array.prototype.shift32 = function () {
return (this.shift() << 24) +
(this.shift() << 16) +
(this.shift() << 8) +
(this.shift() );
};
Array.prototype.get32 = function (off) {
return (this[off ] << 24) +
(this[off + 1] << 16) +
(this[off + 2] << 8) +
(this[off + 3] );
};
Array.prototype.push32 = function (num) { Array.prototype.push32 = function (num) {
this.push((num >> 24) & 0xFF, this.push((num >> 24) & 0xFF,
(num >> 16) & 0xFF, (num >> 16) & 0xFF,
(num >> 8) & 0xFF, (num >> 8) & 0xFF,
(num ) & 0xFF ); (num ) & 0xFF );
}; };
Array.prototype.push32le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF,
(num >> 16) & 0xFF,
(num >> 24) & 0xFF );
};
Array.prototype.shiftStr = function (len) {
var arr = this.splice(0, len);
return arr.map(function (num) {
return String.fromCharCode(num); } ).join('');
};
Array.prototype.pushStr = function (str) {
var i, n = str.length;
for (i=0; i < n; i+=1) {
this.push(str.charCodeAt(i));
}
};
Array.prototype.shiftBytes = function (len) {
return this.splice(0, len);
};
/* /*
* ------------------------------------------------------ * ------------------------------------------------------
......
...@@ -45,6 +45,17 @@ ...@@ -45,6 +45,17 @@
var ANDsz = w * h * 4; var ANDsz = w * h * 4;
var XORsz = Math.ceil( (w * h) / 8.0 ); var XORsz = Math.ceil( (w * h) / 8.0 );
// Push multi-byte little-endian values
arr.push16le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF );
};
arr.push32le = function (num) {
this.push((num ) & 0xFF,
(num >> 8) & 0xFF,
(num >> 16) & 0xFF,
(num >> 24) & 0xFF );
};
// Main header // Main header
arr.push16le(0); // Reserved arr.push16le(0); // Reserved
......
<html> <html>
<head> <head>
<title>VNC Test</title> <title>VNC Playback</title>
<link rel="stylesheet" href="include/plain.css"> <link rel="stylesheet" href="include/plain.css">
</head> </head>
<body> <body>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment