mirror of
https://github.com/kasmtech/KasmVNC.git
synced 2025-06-27 05:01:41 +02:00
VNC-127 Introduce TBB task arena for optimized parallel execution
This commit is contained in:
parent
c89bf7b119
commit
b51a09c477
@ -44,6 +44,7 @@
|
||||
#include <rfb/TightWEBPEncoder.h>
|
||||
#include <rfb/TightQOIEncoder.h>
|
||||
#include <execution>
|
||||
#include <tbb/parallel_for.h>
|
||||
|
||||
using namespace rfb;
|
||||
|
||||
@ -210,6 +211,9 @@ EncodeManager::EncodeManager(SConnection* conn_, EncCache *encCache_) : conn(con
|
||||
dynamicQualityMin = Server::dynamicQualityMin;
|
||||
dynamicQualityOff = Server::dynamicQualityMax - Server::dynamicQualityMin;
|
||||
}
|
||||
|
||||
const auto num_cores = tbb::this_task_arena::max_concurrency() / 2;
|
||||
arena.initialize(num_cores);
|
||||
}
|
||||
|
||||
EncodeManager::~EncodeManager()
|
||||
@ -1237,12 +1241,13 @@ void EncodeManager::writeRects(const Region& changed, const PixelBuffer* pb,
|
||||
}
|
||||
scalingTime = msSince(&scalestart);
|
||||
|
||||
std::for_each(std::execution::par_unseq, std::begin(indices), std::end(indices), [&](size_t i)
|
||||
{
|
||||
encoderTypes[i] = getEncoderType(subrects[i], pb, &palettes[i], compresseds[i],
|
||||
arena.execute([&] {
|
||||
tbb::parallel_for(static_cast<size_t>(0), subrects_size, [&](size_t i) {
|
||||
encoderTypes[i] = getEncoderType(subrects[i], pb, &palettes[i], compresseds[i],
|
||||
&isWebp[i], &fromCache[i],
|
||||
scaledpb, scaledrects[i], ms[i]);
|
||||
checkWebpFallback(start);
|
||||
checkWebpFallback(start);
|
||||
});
|
||||
});
|
||||
|
||||
for (uint32_t i = 0; i < subrects_size; ++i) {
|
||||
|
@ -32,6 +32,7 @@
|
||||
|
||||
#include <stdint.h>
|
||||
#include <atomic>
|
||||
#include <tbb/task_arena.h>
|
||||
#include <sys/time.h>
|
||||
|
||||
namespace rfb {
|
||||
@ -167,6 +168,7 @@ namespace rfb {
|
||||
|
||||
protected:
|
||||
SConnection *conn;
|
||||
tbb::task_arena arena;
|
||||
|
||||
std::vector<Encoder*> encoders;
|
||||
std::vector<int> activeEncoders;
|
||||
|
Loading…
x
Reference in New Issue
Block a user