diff options
author | Pierre Ossman <ossman@cendio.se> | 2015-11-24 17:15:16 +0100 |
---|---|---|
committer | Pierre Ossman <ossman@cendio.se> | 2015-11-27 11:16:15 +0100 |
commit | 2b8aa354684ee25821ab2c8be8ba988cf95e4bb9 (patch) | |
tree | 271ee0dc58d125c07e0a631c2204098419d6615e /common/rfb/DecodeManager.cxx | |
parent | a0eb1e8af915201a260bac19d33fee76faf665ca (diff) | |
download | tigervnc-2b8aa354684ee25821ab2c8be8ba988cf95e4bb9.tar.gz tigervnc-2b8aa354684ee25821ab2c8be8ba988cf95e4bb9.zip |
Optimised shortcut for decoding on single CPU systems
Diffstat (limited to 'common/rfb/DecodeManager.cxx')
-rw-r--r-- | common/rfb/DecodeManager.cxx | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/common/rfb/DecodeManager.cxx b/common/rfb/DecodeManager.cxx index d7cffcfd..a655c53a 100644 --- a/common/rfb/DecodeManager.cxx +++ b/common/rfb/DecodeManager.cxx @@ -56,7 +56,12 @@ DecodeManager::DecodeManager(CConnection *conn) : // wasting CPU fighting for locks if (cpuCount > 4) cpuCount = 4; - vlog.info("Creating %d decoder thread(s)", (int)cpuCount); + // The overhead of threading is small, but not small enough to + // ignore on single CPU systems + if (cpuCount == 1) + vlog.info("Decoding data on main thread"); + else + vlog.info("Creating %d decoder thread(s)", (int)cpuCount); } while (cpuCount--) { @@ -116,6 +121,17 @@ void DecodeManager::decodeRect(const Rect& r, int encoding, decoder = decoders[encoding]; + // Fast path for single CPU machines to avoid the context + // switching overhead + if (threads.size() == 1) { + bufferStream = freeBuffers.front(); + bufferStream->clear(); + decoder->readRect(r, conn->getInStream(), conn->cp, bufferStream); + decoder->decodeRect(r, bufferStream->data(), bufferStream->length(), + conn->cp, pb); + return; + } + // Wait for an available memory buffer queueMutex->lock(); |