Feature request #2037

Enable multi-threaded rendering in QGIS

Added by Tim Sutton over 14 years ago. Updated about 10 years ago.

Status:Closed
Priority:Normal
Assignee:-
Category:Map Canvas
Pull Request or Patch supplied:No Resolution:
Easy fix?:No Copied to github as #:12097

Description

User story 1: Joe has a multicore processor but when QGIS is rendering a map, one of the cores is heavily utilised whilst the rest remain idle.

User story 2: Pam wishes she didnt need to wait so long for maps to draw as each layer draw carries out a long running query against a database backend.

Qt4 includes QThread which makes writing multithreaded cross platform libraries fairly easily. Thus it would be good to start thinking about how we can make QGIS take advantage of this.

In my mind there are two main areas of work required:

  • making map layers inherit from QThread and adding in sufficient foundation for them to be able to render in a thread (pretty much covered in the attached patch).
  • Updating qgsmaprenderer.cpp to orchestrate the threaded rendering of map layers and the composition of the results.

For the second (renderer part) we will need to split the render process into three parts I think:

  • a setup phase which sets the render context for each maplayer (which would need to become a member of qgsmaplayer) and then calls the run() method to launch the thread
  • a slot to listen for when each thread is done and tally up when all the rendering work is completed
  • a finalise method to end the render process with label and acetate rendering and perform final compositing from layer render cache images.

qgis_threaded_render.v1.diff Magnifier - first draft of patch - makes maplayers qthread children (4.55 KB) Tim Sutton, 2009-10-27 04:05 PM


Related issues

Related to QGIS Application - Bug report #8889: Slow "selection" of features Closed 2013-10-17

History

#1 Updated by Marco Hugentobler over 14 years ago

Hi Tim

Please also consider the QtConcurrent (http://doc.trolltech.com/4.5/threads.html#qtconcurrent) framework as an option. The advantage over inheritance from QThread is that the number of created threads automatically adapts depending on the number of cores. Furthermore it is more high-level and therefore simpler to use. And it does not require api changes in QgsMapLayer.

The Qt doc about QtConcurrent is not as good as the usual Qt docs. I once wrote an example to render a tiled raster in threads with QtConcurrent. We may look at this next week.

cheers,
Marco

#2 Updated by Martin Dobias over 14 years ago

I'd like to second Marco's suggestion. Inheriting map layers from QThread looks like a bad design decision...

#3 Updated by Paolo Cavallini almost 14 years ago

There is an ongoing Summer of Code project dealing with this. Hopefully we'll see the results in a couple of months

#4 Updated by Aren Cambre over 12 years ago

  • Assignee deleted (nobody -)
  • Operating System deleted (Debian)
  • Pull Request or Patch supplied set to No

Has anything come of this?

#5 Updated by Giovanni Manghi over 12 years ago

  • Target version changed from Version 1.7.0 to Version 1.7.4

#6 Updated by Aren Cambre over 12 years ago

Oh, wow, this will really come with 1.7.4?

#7 Updated by Nathan Woodrow over 12 years ago

  • Target version changed from Version 1.7.4 to Version 2.0.0

No. I would say that last update was a mistake.

2.0 would be the best target as I haven't seen much work on this in a while.

#8 Updated by Aren Cambre over 12 years ago

OK, thanks. This would be an exciting improvement. Is "low" priority really correct?

#9 Updated by Pirmin Kalberer over 11 years ago

  • Target version changed from Version 2.0.0 to Future Release - Nice to have

#10 Updated by Aren Cambre almost 11 years ago

I'm surprised this remains low priority. This would be a huge benefit for complex maps.

#11 Updated by Nathan Woodrow almost 11 years ago

It's not really low as Martin is planning to work on it after 2.0.

#12 Updated by Aren Cambre almost 11 years ago

  • Priority changed from Low to Normal

#13 Updated by Tim Sutton about 10 years ago

  • Status changed from Open to Closed

I'm closing this out - Martin Dobias has an implementation in a branch which will be merged post QGIS 2.2

Also available in: Atom PDF