Using thread local variables instead of the global ones

Frank Warmerdam warmerdam at POBOX.COM
Thu Apr 27 19:57:15 EDT 2006


Szekeres Tamás wrote:
> Developers,
> 
>  
> 
> According to the IRC conversation with Frank I would like to get to know 
> the developer's affinity of this issue.
> 
>  
> 
> So it would be worth considering to make a support for using thread 
> local variables instead of the global ones in the mapserver code.
> 
> 1. It would add a significal increment on the performace of the 
> applications having high number of multiple threads simultaneously.

Tamas,

I am assuming you feel we would get a performance boost because we
could remove "big locks" around stuff like that parser.  Is that right?

> 2. This activity could bring in a more feasible support for some 
> application models not really supported now like Microsoft ASP.NET
> 
> 3. May result in higher clarity of the code by determining the variables 
> affected by multiple threads.
> 
> The main drawback of this proposal is the need of to look over most of 
> the existing code. 
> 
> Frank has already worked on a solution targeting this problem for GDAL 
> to utilize the Win32 TLS API and the Pthreads implementation.
> 
> In addition I would suggest to rely on the strorage specifiers existing 
> for many of the platforms. It would be quite an easy to integrate into the
> 
> existing code, like:

It has been my finding that __declspec(thread) on win32 only works for
object code in an executable or a directly linked DLL.  A DLL loaded
at runtime using LoadLibrary() will not have it's threadlocal data
properly initialized.

This is the reason I ended up having to go to the much more complicated
mechanisms I currently use in GDAL.

This wouldn't be an issue for mapserv.exe, but it would be for any of the
mapscripts that dynamically load mapserver object code.  Certainly this
affects PHP and Python.

As such, I think the "marking as thread local" approach is not going to be
of real use for mapserver - to my great annoyance.

Best regards,
-- 
---------------------------------------+--------------------------------------
I set the clouds in motion - turn up   | Frank Warmerdam, warmerdam at pobox.com
light and sound - activate the windows | http://pobox.com/~warmerdam
and watch the world go round - Rush    | President OSGF, http://osgeo.org



More information about the mapserver-dev mailing list