GDAL Mutex contention

classic Classic list List threaded Threaded
3 messages Options
john stone john stone
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

GDAL Mutex contention

This post was updated on .
Hi,

I'm loading a lot of icon point substitutions using "feature_geom" model with the "ogr" feature driver.

    <model name="towers" driver="feature_geom">
        <features name="towersFeature" driver="ogr">
            <url>towers.shp</url>
        </features>

        <layout crop_features="false" tile_size_factor="33">
            <level max_range="50000"/>
        </layout>
       
        <styles>
            <style type="text/css"> towers { icon: "tower.png"; icon-placement: centroid; icon-scale: 0.25; render-lighting: false; render-depth-test: false; render-order: 7; } </style>        </styles>
       
        <instancing>true</instancing>
               
    </model>

I'm getting mutex contention on the global GDAL_SCOPED_LOCK between the databasePager threads and my application thread.

The database pager threads are incrementally loading the large towers.shp file and the application thread is updating a PlaceNode and a LocalGeometry node with node->setPosition(GeoPoint()).   The setPosition() call goes through and does a srs->transform() which also uses the GDAL_SCOPED_LOCK.

This global lock completely breaks the intended behavior of the database pager (loading stuff in the background) by serializing access between the two threads.

GDAL has been thread-safe since release 2.0  https://trac.osgeo.org/gdal/wiki/FAQMiscellaneous

Is this global lock still necessary?

J.
john stone john stone
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GDAL Mutex contention

I found this note from back in 2011:

https://lists.osgeo.org/pipermail/gdal-dev/2011-September/030152.html

Given this wouldn't it be possible to update osgEarth/SpatialReference to use a unique OGRCoordinateTransformation per thread ... perhaps by using thread-local-storage ?

J.
gwaldron gwaldron
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: GDAL Mutex contention

In reply to this post by john stone
John,

In you infer from the vague statements in the FAQ that GDAL is now in fact thread-safe in "most situations," then indeed we should be able to re-architect various parts of osgEarth that rely on the mutex in order to function without crashing. I would like to make it happen; it is a chunk of work, and we will need to find some sponsorship to take it on and do it properly.
Glenn Waldron / Pelican Mapping
Loading...