Improve multi-threaded scaling in BitmapScaleSuperFilter

Desktop / LibreOffice - Toma┼ż Vajngerl [collabora.co.uk] - 13 April 2019 02:23 EDT

The old approach was to calculate the number of stripes of the bitmap per thread and later create the exact number tasks (ScaleTask) as there are threads, where each task would process stripes it had been given. This is needlesly complicated as the job of a thread pool is to properly delegate the tasks between threads. This was now changed so that we create one stripe per ScaleTask and let the threadpool delegate the tasks to its threads (that are available).

It also wanted to be clever and use the main thread to do the work also, but it had a major flaw. The threadpool started to process the tasks only when "waitUntilDone" method was called, but the code first processed its slices and then called the threadpool method to start processing. Because of this the performance of scaling wasn't as good as it could be.

This behaviour was now changed so that the main thread isn't involved in processing. It just creates the task, runs the threadpool and waits until the tasks are finished.

Change-Id: I1e8c733bdbced8867d0a7f1190f0421a0cc3e067 Reviewed-on: https://gerrit.libreoffice.org/70668

9695896d8f0e Improve multi-threaded scaling in BitmapScaleSuperFilter
vcl/qa/cppunit/BitmapTest.cxx | 94 ++++++++++++++++++++++++++++
vcl/source/bitmap/BitmapScaleSuperFilter.cxx | 72 +++++++++++----------
2 files changed, 129 insertions(+), 37 deletions(-)

Upstream: cgit.freedesktop.org


  • Share