This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: vector lightweight debug mode
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: François Dumont <frs dot dumont at gmail 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: Mon, 16 Nov 2015 10:29:23 +0000
- 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>
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 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 :-)
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.
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.