grep-commit
[Top][All Lists]
Advanced

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

grep branch, master, updated. v2.21-52-gd940cf0


From: Jim Meyering
Subject: grep branch, master, updated. v2.21-52-gd940cf0
Date: Sat, 18 Jul 2015 18:30:17 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "grep".

The branch, master has been updated
       via  d940cf045c4e777d37b19ee4639623f2c4a7e062 (commit)
       via  256a4b494fe1c48083ba73b4f62607234e4fefd5 (commit)
      from  3f50c6f0b09dd5be1b3d8413eb0be606fe48599d (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/grep.git/commit/?id=d940cf045c4e777d37b19ee4639623f2c4a7e062


commit d940cf045c4e777d37b19ee4639623f2c4a7e062
Author: Jim Meyering <address@hidden>
Date:   Sun Jul 5 11:43:47 2015 -0700

    tests: add a test for the performance fix
    
    * tests/long-pattern-perf: New file.
    * tests/Makefile.am (TESTS): Add it.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 629d322..c95d5a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -80,6 +80,7 @@ TESTS =                                               \
   khadafy                                      \
   kwset-abuse                                  \
   long-line-vs-2GiB-read                       \
+  long-pattern-perf                            \
   match-lines                                  \
   max-count-overread                           \
   max-count-vs-context                         \
diff --git a/tests/long-pattern-perf b/tests/long-pattern-perf
new file mode 100755
index 0000000..cba6553
--- /dev/null
+++ b/tests/long-pattern-perf
@@ -0,0 +1,50 @@
+#!/bin/sh
+# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
+
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_timeout_
+require_hi_res_time_
+
+fail=0
+
+echo x > in || framework_failure_
+# We could use seq -s '' (avoiding the tr filter), but I
+# suspect some version of seq does not honor that option.
+# Note that we want 10x the byte count (not line count) in the larger file.
+seq 5000  | tr -d '\012' > re     || framework_failure_
+seq 40000 | tr -d '\012' > re-10x || framework_failure_
+
+start=$(hi_res_time_)
+grep -f re in; st=$?
+stop=$(hi_res_time_)
+test $st = 1 || fail=1
+
+# Increasing the length of the regular expression by a factor
+# of 10 should cause no more than a 10x increase in duration.
+# However, we'll draw the line at 30x to avoid false-positives.
+# Use an integer; some 'timeout' implementations have trouble with
+# floating-point.
+n_sec=$(
+  $AWK 'BEGIN { print 1 + int (30 * ('$stop' - '$start'))}' < /dev/null
+)
+
+# Expect no match, i.e., exit status of 1.  Anything else is an error.
+timeout $n_sec grep -f re-10x in; st=$?
+test $st = 1 || fail=1
+
+Exit $fail

http://git.savannah.gnu.org/cgit/grep.git/commit/?id=256a4b494fe1c48083ba73b4f62607234e4fefd5


commit d940cf045c4e777d37b19ee4639623f2c4a7e062
Author: Jim Meyering <address@hidden>
Date:   Sun Jul 5 11:43:47 2015 -0700

    tests: add a test for the performance fix
    
    * tests/long-pattern-perf: New file.
    * tests/Makefile.am (TESTS): Add it.

diff --git a/tests/Makefile.am b/tests/Makefile.am
index 629d322..c95d5a9 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -80,6 +80,7 @@ TESTS =                                               \
   khadafy                                      \
   kwset-abuse                                  \
   long-line-vs-2GiB-read                       \
+  long-pattern-perf                            \
   match-lines                                  \
   max-count-overread                           \
   max-count-vs-context                         \
diff --git a/tests/long-pattern-perf b/tests/long-pattern-perf
new file mode 100755
index 0000000..cba6553
--- /dev/null
+++ b/tests/long-pattern-perf
@@ -0,0 +1,50 @@
+#!/bin/sh
+# grep-2.21 would incur a 100x penalty for 10x increase in regexp length
+
+# Copyright 2015 Free Software Foundation, Inc.
+
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+
+. "${srcdir=.}/init.sh"; path_prepend_ ../src
+require_timeout_
+require_hi_res_time_
+
+fail=0
+
+echo x > in || framework_failure_
+# We could use seq -s '' (avoiding the tr filter), but I
+# suspect some version of seq does not honor that option.
+# Note that we want 10x the byte count (not line count) in the larger file.
+seq 5000  | tr -d '\012' > re     || framework_failure_
+seq 40000 | tr -d '\012' > re-10x || framework_failure_
+
+start=$(hi_res_time_)
+grep -f re in; st=$?
+stop=$(hi_res_time_)
+test $st = 1 || fail=1
+
+# Increasing the length of the regular expression by a factor
+# of 10 should cause no more than a 10x increase in duration.
+# However, we'll draw the line at 30x to avoid false-positives.
+# Use an integer; some 'timeout' implementations have trouble with
+# floating-point.
+n_sec=$(
+  $AWK 'BEGIN { print 1 + int (30 * ('$stop' - '$start'))}' < /dev/null
+)
+
+# Expect no match, i.e., exit status of 1.  Anything else is an error.
+timeout $n_sec grep -f re-10x in; st=$?
+test $st = 1 || fail=1
+
+Exit $fail

-----------------------------------------------------------------------

Summary of changes:
 NEWS                                               |    2 +
 src/dfa.c                                          |   53 ++++++++++++++-----
 tests/Makefile.am                                  |    1 +
 .../{mb-non-UTF8-performance => long-pattern-perf} |   31 ++++++------
 4 files changed, 58 insertions(+), 29 deletions(-)
 copy tests/{mb-non-UTF8-performance => long-pattern-perf} (58%)


hooks/post-receive
-- 
grep



reply via email to

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