grep-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Grep-devel] [PATCH 2/2] grep: speed up Aho-Corasick when at most 2


From: Jim Meyering
Subject: Re: [Grep-devel] [PATCH 2/2] grep: speed up Aho-Corasick when at most 2 bytes
Date: Mon, 30 Jan 2017 14:24:39 -0800

On Mon, Jan 30, 2017 at 12:47 AM, Paul Eggert <address@hidden> wrote:
> Norihiro Tanaka wrote:
>>
>> However, Slight slowdown may be caused in following case.
>>
>>   yes $(printf 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c) | head -1000000
>> >inp
>>   time -p src/grep -F -e 0b -e ab inp
>>
>> I think that it is not enough to mind.
>
>
> It'd be a pain to attack that problem seriously, and perhaps you're right
> it's not worth worrying about. Still, we can do minor tuning that should be
> relatively simple and trouble-free. How about the attached patch? On my
> platform it improves CPU performance on the above benchmark by about 23%.

On an idle 3-year old i7-4770S with plenty of RAM, I ran the following
 commands before and after the patch, taking the best time out of 10:

  yes $(printf 0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c0c) | head -20000000 >inp
  for i in $(seq 10); do env time src/grep -F -e 0b -e ab inp; done

Before the patch, the best was 03.39elapsed.
After, it was 03.13elapsed, i.e., taking 7.6% less time.
I compiled with -O2 and a very recent gcc: version 7.0.1 20170127
(experimental) (GCC)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]