Re: git grep performance regression
- From
Duy Nguyen <pclouds@gmail.com>
- Date
- Jan 15, 2013, 04:38 UTC
- Message-ID
- <CACsJy8AnABCisgSVL7Qh_-uejAJA3x1kzy=4i+uXm3+90m5tuA@mail.gmail.com>
- In-Reply-To
- <CACsJy8A7FLYqdY2Mt5pUq0nH3N8mbZ4crkYJYFfepp19c0aWhg@mail.gmail.com>
On Tue, Jan 15, 2013 at 9:46 AM, Duy Nguyen <pclouds@gmail.com> wrote:
> I don't have time to look into details now, but by enabling > DEBUG_ATTR, it looks like this commit makes it push and pop patterns a > lot more than without the commit.
I think the culprit is at this chunk:
static void prepare_attr_stack(const char *path)
{
struct attr_stack *elem, *info;
int dirlen, len;
const char *cp;- cp = strrchr(path, '/'); - if (!cp) - dirlen = 0; - else - dirlen = cp - path; + dirlen = find_basename(path) - path;
dirlen is not expected to include the trailing slash, but find_basename() does that. It messes up with the path filters for push/pop in the next code. This brings grep performance closely back to before for me. Ross, can you check (patch could be whitespace damaged by gmail)?
-- 8< --
diff --git a/attr.c b/attr.c index b05110d..1e96e26 100644 --- a/attr.c +++ b/attr.c @@ -583,6 +583,9 @@ static void prepare_attr_stack(const char *path) dirlen = find_basename(path) - path; + if (dirlen) + dirlen--; + /* * At the bottom of the attribute stack is the built-in * set of attribute definitions, followed by the contents -- 8< --