From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-6.3 required=3.0 tests=AWL,BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, RCVD_IN_DNSWL_HI,RP_MATCHES_RCVD shortcircuit=no autolearn=ham autolearn_force=no version=3.4.0 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by dcvr.yhbt.net (Postfix) with ESMTP id 876301F4F8 for ; Sun, 25 Sep 2016 14:02:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756202AbcIYOCP (ORCPT ); Sun, 25 Sep 2016 10:02:15 -0400 Received: from mout.gmx.net ([212.227.17.21]:55800 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756006AbcIYOCO (ORCPT ); Sun, 25 Sep 2016 10:02:14 -0400 Received: from virtualbox ([108.198.118.51]) by mail.gmx.com (mrgmx103) with ESMTPSA (Nemesis) id 0MYwQh-1bRHw212A7-00Vgph; Sun, 25 Sep 2016 16:02:02 +0200 Date: Sun, 25 Sep 2016 16:01:54 +0200 (CEST) From: Johannes Schindelin X-X-Sender: virtualbox@virtualbox To: Jeff King cc: git@vger.kernel.org, Junio C Hamano , Benjamin Kramer , =?UTF-8?Q?Ren=C3=A9_Scharfe?= Subject: Re: [PATCH v4 3/3] regex: use regexec_buf() In-Reply-To: <20160921220310.5wk76qdsjyhvstk4@sigill.intra.peff.net> Message-ID: References: <53f3609d99c865d59d7bfd8219a5334339e9e6bc.1474482164.git.johannes.schindelin@gmx.de> <20160921220310.5wk76qdsjyhvstk4@sigill.intra.peff.net> User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags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qgK0eQ1igaG5M0wgqhcdU2JklU+Dh9KhaVe6Xp97a pDo4LUQ Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi Peff, On Wed, 21 Sep 2016, Jeff King wrote: > On Wed, Sep 21, 2016 at 08:24:14PM +0200, Johannes Schindelin wrote: > > > The new regexec_buf() function operates on buffers with an explicitly > > specified length, rather than NUL-terminated strings. > > > > We need to use this function whenever the buffer we want to pass to > > regexec() may have been mmap()ed (and is hence not NUL-terminated). > > > > Note: the original motivation for this patch was to fix a bug where > > `git diff -G ` would crash. This patch converts more callers, > > though, some of which explicitly allocated and constructed > > NUL-terminated strings (or worse: modified read-only buffers to insert > > NULs). > > Nice. I probably would have split these into their own patch, but I > think it is OK here. True. I guess I was a little lazy... > > @@ -228,18 +227,16 @@ static long ff_regexp(const char *line, long len, > > len--; > > } > > > > - line_buffer = xstrndup(line, len); /* make NUL terminated */ > > - > > Nice to see this one going away in particular, since it's called quite a > lot. According to perf, "git log -p" on git.git drops about 1.5 million > malloc calls (about 9% of the total). And here are best-of-five results > for that same command: > > [before] > real 0m14.676s > user 0m13.988s > sys 0m0.676s > > [after] > real 0m14.394s > user 0m13.624s > sys 0m0.760s > > Not a _huge_ improvement, but more significant than the run-to-run > noise. Oh, that's nice! As you guessed, my aim was not to improve performance, but it is a pretty side effect... Thanks for testing! Dscho