Nyall Dawson b3256ad2c3 [python] Always release the GIL before calling PyQGIS c++ methods
Switches on the sip "-g" switch, which forces sip to release the
Python Global Interpreter Lock before calling a qgis c++ method,
and reacquire it after.

While this flag is not a default sip flag, it is used when building
the PyQt API, so can't forsee any issues from enabling it.

The benefit however is extreme for PyQGIS based scripts which
rely on threads, potentially resulting in massive performance
boosts.

Without this switch, calling an expensive c++ method (say,
building a QgsSpatialIndex using a QgsFeatureIterator) would lock
the Python GIL for the duration of the c++ call... which could
potentially take minutes or more. With the switch, the lock
is released before all calls, so other Python threads are free
to merrily grab the lock and do other processing while the
original thread chugs away in c++ land.

Benchtests of worst-case scenarios (single thread calling
thousands of very inexpensive PyQGIS methods (simple getters))
regressed from mean of 154 seconds to 158 with this flag. But
that's worst case (and as Intel have recently demonstrated...
we can't take yesterday's computing speed as the benchmark
for todays ;). Given that best case scenarious (multi-threaded
operations calling slow c++ methods) will benefit so greatly
from this change, I think it's an acceptable trade off.

*This is a step toward potentially re-enabling background
execution of python based Processing algorithms, and also
should greatly improve QGIS responsiveness when using
python based renderers/symbols.
2018-01-26 14:55:31 +10:00
..
2017-10-29 10:46:54 -05:00
2018-01-22 18:50:43 +02:00
2017-10-16 22:34:37 +02:00
2018-01-17 10:16:37 -04:00
2017-11-05 21:03:08 +01:00