Subject: Re: bug#16232: [PATCH] grep: make --ignore-case (-i) faster (sometimes 10x) in multibyte locales

From: Norihiro Tanaka <[email-masked]>
Date: Wed, 19 Feb 2014 23:22:08 +0900

Hi,

Slow down may be caused by the patch, because MBCSET is processed by not
DFA engine but regexp engine.

I tested performance on grep-2.17 and the version which the patch is reverted.
Latter is 100x faster.

yes $(printf '%078dm' 0)|head -10000 > in

grep-2.17 original:
$ for i in $(seq 10); do env LC_ALL=ja_JP.eucJP time src/grep -i n in; done
Command exited with non-zero status 1
5.92user 1.69system 0:07.73elapsed 98%CPU (0avgtext+0avgdata 3856maxresident)k
0inputs+0outputs (0major+422minor)pagefaults 0swaps
Command exited with non-zero status 1
5.59user 1.87system 0:07.58elapsed 98%CPU (0avgtext+0avgdata 3872maxresident)k
0inputs+0outputs (0major+423minor)pagefaults 0swaps
Command exited with non-zero status 1
6.06user 1.58system 0:07.81elapsed 97%CPU (0avgtext+0avgdata 3872maxresident)k
0inputs+0outputs (0major+423minor)pagefaults 0swaps
Command exited with non-zero status 1
5.73user 1.66system 0:07.52elapsed 98%CPU (0avgtext+0avgdata 3856maxresident)k
0inputs+0outputs (0major+422minor)pagefaults 0swaps
Command exited with non-zero status 1
6.42user 1.19system 0:07.86elapsed 96%CPU (0avgtext+0avgdata 3872maxresident)k
0inputs+0outputs (0major+423minor)pagefaults 0swaps
Command exited with non-zero status 1
6.15user 1.56system 0:08.34elapsed 92%CPU (0avgtext+0avgdata 3888maxresident)k
0inputs+0outputs (0major+424minor)pagefaults 0swaps
Command exited with non-zero status 1
6.97user 0.61system 0:07.77elapsed 97%CPU (0avgtext+0avgdata 3856maxresident)k
0inputs+0outputs (0major+422minor)pagefaults 0swaps
Command exited with non-zero status 1
7.00user 0.57system 0:07.71elapsed 98%CPU (0avgtext+0avgdata 3872maxresident)k
0inputs+0outputs (0major+423minor)pagefaults 0swaps
Command exited with non-zero status 1
7.16user 0.25system 0:07.56elapsed 97%CPU (0avgtext+0avgdata 3872maxresident)k
0inputs+0outputs (0major+423minor)pagefaults 0swaps
Command exited with non-zero status 1
7.04user 0.39system 0:07.60elapsed 97%CPU (0avgtext+0avgdata 3856maxresident)k
0inputs+0outputs (0major+422minor)pagefaults 0swaps

After revert the patch:
$ for i in $(seq 10); do env LC_ALL=ja_JP.eucJP time src/grep -i n in; done
Command exited with non-zero status 1
0.07user 0.02system 0:00.10elapsed 92%CPU (0avgtext+0avgdata 3072maxresident)k
0inputs+0outputs (0major+232minor)pagefaults 0swaps
Command exited with non-zero status 1
0.03user 0.01system 0:00.05elapsed 101%CPU (0avgtext+0avgdata 3072maxresident)k
0inputs+0outputs (0major+218minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.01system 0:00.06elapsed 90%CPU (0avgtext+0avgdata 3072maxresident)k
0inputs+0outputs (0major+218minor)pagefaults 0swaps
Command exited with non-zero status 1
0.03user 0.02system 0:00.05elapsed 103%CPU (0avgtext+0avgdata 3056maxresident)k
0inputs+0outputs (0major+217minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.01system 0:00.06elapsed 86%CPU (0avgtext+0avgdata 3088maxresident)k
0inputs+0outputs (0major+219minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.01system 0:00.06elapsed 91%CPU (0avgtext+0avgdata 3056maxresident)k
0inputs+0outputs (0major+217minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.01system 0:00.06elapsed 87%CPU (0avgtext+0avgdata 3056maxresident)k
0inputs+0outputs (0major+217minor)pagefaults 0swaps
Command exited with non-zero status 1
0.03user 0.02system 0:00.05elapsed 105%CPU (0avgtext+0avgdata 3072maxresident)k
0inputs+0outputs (0major+218minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.00system 0:00.06elapsed 90%CPU (0avgtext+0avgdata 3072maxresident)k
0inputs+0outputs (0major+218minor)pagefaults 0swaps
Command exited with non-zero status 1
0.04user 0.01system 0:00.06elapsed 90%CPU (0avgtext+0avgdata 3056maxresident)k
0inputs+0outputs (0major+217minor)pagefaults 0swaps

Norihiro