Boost logo

Boost :

Subject: Re: [boost] [GGL] [geometry] Inexplicable speed benefit when using Visual C++ 2010
From: Tanguy Fautré (tfautre_at_[hidden])
Date: 2010-04-16 15:44:12


On 16/04/2010 20:06, eg wrote:
> On 4/16/2010 9:04 AM, Giovanni Piero Deretta wrote:
>>
>> VC++ 2010 now has the iterator checking disabled by default; It is
>> probably unlikely that you were unknowingly running with checking
>> enabled, but that would easily explain the speedup.
>>
> Does anyone have a reference to confirm the above?
>
> I have googled away but have found no evidence to support this. It would
> be great news indeed, as the burden of using _SECURE_SCL
> consistent/correct across a set of 3rd party libraries is too high.

"Friday, June 26, 2009 2:47 PM by Stephan T. Lavavej [MSFT]
[...]
Fortunately, VC10 after Beta 1 will contain "#pragma detect_mismatch",
which will detect _ITERATOR_DEBUG_LEVEL mismatch deterministically at
link time, instead of crashing mysteriously at run time.

> Is the default in release mode now to turn SECURE_SCL off?

In VC10 after Beta 1, _ITERATOR_DEBUG_LEVEL in release mode will default
to 0. And there was much rejoicing."
(http://blogs.msdn.com/vcblog/archive/2009/06/23/stl-performance.aspx)

I can confirm both points (see [1] and [2]). I'm really glad VS team
finally listened and disabled checked iterators by default in release
mode. The ODR violation check is just the cherry on the top.

 From what I understand, a new macro, _ITERATOR_DEBUG_LEVEL, supersedes
both _SECURE_SCL and _ITERATOR_DEBUG_LEVEL. By default,
_ITERATOR_DEBUG_LEVEL is set to 2 in Debug mode and to 0 in Release mode.

The documentation is a bit weak, but if you search for
_ITERATOR_DEBUG_LEVEL inside VC header files, you'll see the actual logic.

[1]
http://social.msdn.microsoft.com/Forums/en/vcpluslanguage/thread/47cac5fe-50ac-4f74-bdf0-74cd837f2412

[2] iterator debug level preprocessor checks I've used when testing
VC10, just to be sure.

#if _ITERATOR_DEBUG_LEVEL == 0
#pragma message("_ITERATOR_DEBUG_LEVEL == 0")
#elif _ITERATOR_DEBUG_LEVEL == 1
#pragma message("_ITERATOR_DEBUG_LEVEL == 1")
#elif _ITERATOR_DEBUG_LEVEL == 2
#pragma message("_ITERATOR_DEBUG_LEVEL == 2")
#endif

#if _ITERATOR_DEBUG_LEVEL == 0 && _SECURE_SCL != 0
#error _SECURE_SCL != 0 while _ITERATOR_DEBUG_LEVEL == 0
#endif


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk