This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: vector lightweight debug mode
- From: FranÃois Dumont <frs dot dumont at gmail dot com>
- To: Jonathan Wakely <jwakely at redhat dot com>
- Cc: Jonathan Wakely <jwakely dot gcc at gmail dot com>, "libstdc++ at gcc dot gnu dot org" <libstdc++ at gcc dot gnu dot org>, gcc-patches <gcc-patches at gcc dot gnu dot org>
- Date: Tue, 17 Nov 2015 20:49:23 +0100
- Subject: Re: vector lightweight debug mode
- Authentication-results: sourceware.org; auth=none
- References: <20150914195038 dot GQ2631 at redhat dot com> <55F9C4F6 dot 6030706 at gmail dot com> <20150916202953 dot GE2631 at redhat dot com> <55FD0F35 dot 4010106 at gmail dot com> <CAH6eHdSzU-HB_0R82HDdFkHy3tMraDw+OGU8AfTY7Gqx8MSMGA at mail dot gmail dot com> <CAH6eHdSR-GM2uYUOyxmi6voLOn1CreSFp=tVRJigf9oSDCZ_dQ at mail dot gmail dot com> <561574BE dot 1060005 at gmail dot com> <20151007200917 dot GU12094 at redhat dot com> <561C0D3A dot 7010504 at gmail dot com> <5648F551 dot 5030404 at gmail dot com> <20151116102923 dot GI2937 at redhat dot com>
On 16/11/2015 11:29, Jonathan Wakely wrote:
> On 15/11/15 22:12 +0100, François Dumont wrote:
>> Here is a last version I think.
>>
>> I completed the debug light mode by adding some check on iterator
>> ranges.
>>
>> Even if check are light I made some changes to make sure that
>> internally vector is not using methods instrumented with those checks.
>> This is to make sure checks are not done several times. Doing so also
>> simplify normal mode especially when using insert range, there is no
>> need to check if parameters are integers or not.
>
> Yes, I'd also observed that those improvements could be made, to avoid
> dispatching when we already know we have iterators not integers.
I will keep those simplification even if I remove some checks.
>
>> I also introduce some __builtin_expect to make sure compiler will
>> prefer the best path.
>>
>> I didn't manage to check result on generated code. I am pretty sure
>> there will be an impact, you can't run more code without impact. But
>> that is a known drawback of debug mode, light or not, we just need to
>> minimize it. Mostly by making sure that checks are done only once.
>
> Not doing the checks is also an option. That minimizes the cost :-)
This is controlled by a macro, users already have this option.
>
> For the full debug mode we want to check everything we can, and accept
> that has a cost.
>
> For the lightweight one we need to evaluate the relative benefits. Is
> it worth adding checks for errors that only happen rarely? Does the
> benefit outweigh the cost?
>
> I'm still not convinced that's the case for the "valid range" checks.
> I'm willing to be convinced, but am not convinced yet.
Ok so I will remove this check. And what about insert position check ? I
guess this one too so I will remove it too. Note that will only remain
checks on the most basic operations that is to say those on which the
check will have the biggest impact proportionally.
I would like we push the simplest version so that people can start
experimenting.
I would also prefer concentrate on _GLIBCXX_DEBUG mode :-)
>
>> It would be great to have it for gcc 6.0. I am working on the same
>> for other containers.
>
> Please don't do the valid range checks for std::deque, the checks are
> undefined for iterators into different containers and will not give a
> reliable answer.
But debug mode is full of those checks, no ?
François