From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 119271 invoked by alias); 17 Nov 2015 19:49:33 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 119252 invoked by uid 89); 17 Nov 2015 19:49:32 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mail-wm0-f52.google.com Received: from mail-wm0-f52.google.com (HELO mail-wm0-f52.google.com) (74.125.82.52) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 17 Nov 2015 19:49:31 +0000 Received: by wmww144 with SMTP id w144so169005097wmw.1; Tue, 17 Nov 2015 11:49:28 -0800 (PST) X-Received: by 10.28.216.201 with SMTP id p192mr4722555wmg.29.1447789768267; Tue, 17 Nov 2015 11:49:28 -0800 (PST) Received: from [192.168.0.23] ([82.237.250.248]) by smtp.googlemail.com with ESMTPSA id u17sm25550230wmd.8.2015.11.17.11.49.26 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 17 Nov 2015 11:49:26 -0800 (PST) Subject: Re: vector lightweight debug mode To: Jonathan Wakely References: <20150914195038.GQ2631@redhat.com> <55F9C4F6.6030706@gmail.com> <20150916202953.GE2631@redhat.com> <55FD0F35.4010106@gmail.com> <561574BE.1060005@gmail.com> <20151007200917.GU12094@redhat.com> <561C0D3A.7010504@gmail.com> <5648F551.5030404@gmail.com> <20151116102923.GI2937@redhat.com> Cc: Jonathan Wakely , "libstdc++@gcc.gnu.org" , gcc-patches From: =?UTF-8?Q?Fran=c3=a7ois_Dumont?= X-Enigmail-Draft-Status: N1110 Message-ID: <564B84C3.3090900@gmail.com> Date: Tue, 17 Nov 2015 19:49:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 MIME-Version: 1.0 In-Reply-To: <20151116102923.GI2937@redhat.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-SW-Source: 2015-11/txt/msg02133.txt.bz2 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