source: docs/Working/icGrep/evaluation.tex @ 4502

Last change on this file since 4502 was 4502, checked in by nmedfort, 5 years ago

Revised table

File size: 10.5 KB
Line 
1\section{Evaluation}\label{sec:evaluation}
2
3In this section, we report on the evaluation of ICgrep performance, looking
4at three aspects.   First we consider a performance studies in a series
5of Unicode regular expression search problems in comparison to the
6contemporary competitors, including pcre2grep released in January 2015
7and ugrep of the ICU 54.1 software distribution.  Then we move on to
8investigate some performance aspects of ICgrep internal methods, looking
9at the impact of optimizations and multithreading.
10
11\subsection{Simple Property Expressions}
12
13A key feature of Unicode level 1 support in regular expression engines
14is how the support that they provide for property expressions and combinations of property expressions
15using set union, intersection and difference operators.   Both {\tt ugrep}
16and {\tt icgrep} provide systematic support for all property expressions
17at Unicode Level 1 as well as set union, intersection and difference.
18On the other hand, {\tt pcre2grep} does not support the set intersection and difference operators directly.
19However, these operators can instead be expressed using a regular expression
20feature known as a lookbehind assertion.   Set intersection involves a
21regular expression formed with a one of the property expressions and a
22positive lookbehind assertion on the other, while set difference uses
23a negative lookbehind assertion. 
24
25We generated a set of regular expressions involving all Unicode values of
26the Unicode general category property ({\tt gc}) and all values of the Unicode
27script property ({\tt sc}). 
28We then generated
29expressions involving random pairs of {\tt gc} and {\tt sc}
30values combined with a random set operator chosen from union, intersection and difference.
31All property values are represented at least once.   
32A small number of
33expressions were removed because they involved properties not supported by pcre2grep.
34In the end 246 test expressions were constructed in this process.
35
36We selected a set of Wikimedia XML files in several major languages representing
37most of the world's major language families as a test corpus.   For each program
38under test, we perform searches for each regular expression against each XML document.
39Results are presented in Figure \ref{fig:property_test}.  Performance is reported
40in CPU cycles per byte on an Intel Core i7 machine.   The results were grouped
41by the percentage of matching lines found in the XML document, grouped in
425\% increments.  ICgrep shows dramatically better performance, particularly
43when searching for rare items.
44As shown in the figure, pcre2grep and ugrep both show
45increased performance (reduced CPU cycles per byte) with increasing percentage
46of matches found.  In essence, each match found allows these programs
47to skip the full processing of the rest of the line.   On the other
48hand, icGrep shows a slight drop-off in performance with the number
49of matches found.   This is primarily due to property classes that
50include large numbers of codepoints.   These classes require more
51bitstream equations for calculation and also have a greater probability
52of matching.   Nevertheless, the performance of icGrep in matching
53the defined property expressions is stable and well ahead of the competitors
54in all cases.
55
56\begin{figure}
57\begin{center}
58\pgfplotstableread[col sep = comma]{data/icgrep-scatter.csv}\icgrep
59\pgfplotstableread[col sep = comma]{data/ugrep541-scatter.csv}\ugrep
60\pgfplotstableread[col sep = comma]{data/pcre2grep-scatter.csv}\pcre
61
62\begin{tikzpicture}
63\begin{axis}[
64grid=both,
65x tick label style={ /pgf/number format/1000 sep=},
66ylabel={CPU Cycles Per Byte},
67xlabel={Percentage of Matching Lines},
68minor y tick num={1},
69xmax=100,
70height=0.5\textwidth,
71legend style={at={(1.05,0.5)},
72anchor=west,legend columns=1,
73align=left,draw=none,column sep=2ex}
74]
75\addplot+[no markers,line width=2pt,color=blue!60,solid] table {\icgrep};
76\addplot+[no markers,line width=2pt,color=red!60,solid] table {\ugrep};
77\addplot+[no markers,line width=2pt,color=brown!60,solid] table {\pcre};
78\legend{icGrep,ugrep541,pcre2grep}
79\end{axis}
80
81
82\end{tikzpicture}
83\end{center}
84\caption{Matching Performance for Simple Property Expressions}\label{fig:property_test}
85\end{figure}
86
87\subsection{Complex Expressions}
88
89We also comparative performance of the matching engines on a series
90of more complex expressions as shown in Table \ref{table:complexexpr}.
91
92% \begin{table}
93% \begin{center}
94% \begin{tabular}{|c|r|r|r|}  \hline
95% Regular & \multicolumn{3}{|c|}{CPU cycles per byte} \\ \cline{2-4}
96% Expression & icGrep{} & pcre2grep & ugrep \\ \hline
97% blah  & 1 & 1000 & 100 \\ \hline
98% \end{tabular}
99% \caption{Matching Times for Complex Expressions}\label{table:complexexpr}
100% \end{center}
101% \end{table}
102
103\begin{samepage}
104\begin{table}\centering % requires booktabs
105\small
106\begin{tabular}{@{}p{2.7cm}p{10.8cm}@{}}
107\textbf{Name}&\textbf{Regular Expression}\\
108\toprule
109alphanumeric \#1&\verb`^[\p{L}\p{N}]*((\p{L}\p{N})|(\p{N}\p{L}))[\p{L}\p{N}]*$`\\
110\midrule
111alphanumeric \#2&\verb`[\p{L}\p{N}]*((\p{L}\p{N})|(\p{N}\p{L}))[\p{L}\p{N}]*`\\
112\midrule
113arabic&\verb`^[\p{Arabic}\p{Common}]*\p{Arabic}[\p{Arabic}\p{Common}]*$`\\
114\midrule
115currency&\verb`(\p{Sc}\s*(\d*|(\d{1,3}([,.]\d{3})*))([,.]\d{2}?)?)|`\newline\verb`((\d*|(\d{1,3}([,.]\d{3})*))([,.]\d{2}?)?\s*\p{Sc})`\\
116\midrule
117email &\verb`([^\p{Z}<]+@[\p{L}\p{M}\p{N}.-]+\.(\p{L}\p{M}*){2,6})(>|\p{Z}|$)`\\
118\bottomrule
119\end{tabular}
120\caption{Regular Expressions}\label{table:regularexpr}
121\end{table}
122
123\begin{table}\centering % requires booktabs
124\newcolumntype{T}{c}
125\small
126\begin{tabular}{@{}p{3cm}r@{~--~}rp{4pt}r@{~--~}rp{4pt}r@{~--~}rp{4pt}r@{~--~}rp{4pt}@{}}
127&\multicolumn{6}{c}{\textbf{\icGrep{}}}\\
128\cmidrule[1pt](lr){2-7}
129\cmidrule[1pt](lr){8-10}
130\cmidrule[1pt](lr){11-13}
131\textbf{Expression}&\multicolumn{3}{T}{\textbf{SEQ}}&\multicolumn{3}{T}{\textbf{MT}}&\multicolumn{3}{T}{\textbf{pcre2grep}}&\multicolumn{3}{T}{\textbf{ugrep541}}\\
132\toprule
133Alphanumeric \#1&2.4&5.0&&2.1&4.4&&8.2&11.3&&8.8&11.3&\\
134Alphanumeric \#2&2.3&4.9&&2.0&4.1&&209.9&563.5&&182.3&457.9&\\
135Arabic&1.5&3.4&&1.2&2.6&&7.5&270.8&&8.9&327.8&\\
136Currency&0.7&2.1&&0.4&1.4&&188.4&352.3&&52.8&152.8&\\
137Cyrillic&1.6&3.9&&1.3&2.8&&30.5&49.7&&11.2&20.1&\\
138Email&3.0&6.9&&2.7&6.4&&67.2&1442.0&&108.8&1022.3&\\
139\bottomrule
140\end{tabular}
141\caption{Matching Times for Complex Expressions (Seconds Per GB)}\label{table:complexexpr}
142\end{table}
143
144\end{samepage}
145
146
147
148
149
150
151
152
153
154
155
156
157
158\subsection{Optimizations of Bitwise Methods}
159
160In order to support evaluation of bitwise methods, as well as to support
161the teaching of those methods and ongoing research, \icGrep{} has an array
162of command-line options.   This makes it relatively straightforward
163to report on certain performance aspects of ICgrep, while others require
164special builds. 
165
166For example, the command-line switch {\tt -disable-matchstar} can be used
167to eliminate the use of the MatchStar operation for handling
168Kleene-* repetition of character classes.   In this case, \icGrep{} substitutes
169a while loop that iteratively extends match results.   
170Surprisingly, this
171does not change performance much in many practical cases.   
172In each block,
173the maximum iteration count is the maximum length run encountered; the
174overall performance is based on the average of these maximums throughout the
175file.   But when search for XML tags using the regular expression
176\verb:<[^!?][^>]*>:, a slowdown of more than 2X may be found in files
177with many long tags. 
178
179The {\tt -disable-log2-bounded-repetition} flag allows these
180effectiveness of the special techniques for bounded repetition of
181byte classes to be assessed.   A slowdown of 30\% was observed
182with the searches using the regular expression
183\verb:(^|[ ])[a-zA-Z]{11,33}([.!? ]|$):, for example.
184
185To control the insertion of if-statements into dynamically
186generated code, the
187number of non-nullable pattern elements between the if-tests
188can be set with the {\tt -if-insertion-gap=} option.   The
189default value in \icGrep{} is 3, setting the gap to 100 effectively
190turns of if-insertion.   Eliminating if-insertion sometimes improves
191performance by avoiding the extra if tests and branch mispredications.
192For patterns with long strings, however, there can be a substantial
193slowdown; searching for a pattern of length 40 slows down by more
194than 50\% without the if-statement short-circuiting.
195
196ICgrep also provides options that allow
197various internal representations to be printed out.   These
198can aid in understanding and/or debugging performance issues.
199For example, the option
200{\tt -print-REs} show the parsed regular expression as it goes
201through various transformations.   The internal \Pablo{} code generated
202may be displayed with {\tt -print-\Pablo{}}.  This can be quite useful in
203helping understand the match process.   It also possible to print out the
204generated LLVM IR code ({\tt -dump-generated-IR}), but this may be
205less useful as it includes many
206details of low-level carry-handling that obscures the core logic.
207
208The precompiled calculations of the various Unicode properties
209are each placed in if-hierarchies as described previously.   To assess the
210impact of this strategy, we built a version of icGrep without such
211if-hierarchies.  In this case, when a Unicode property class is defined,
212bitwise logic equations are applied for all members of the class independent
213of the Unicode blocks represented in the input document.   For the classes
214covering the largest numbers of codepoints, we observed slowdowns of up to 5X.
215
216
217% \subsection{Single vs. Multithreaded Performance}
218%
219%
220% \begin{figure}
221% \begin{center}
222% \pgfplotstableread[col sep = comma]{data/icgrep-scatter-mt.csv}\base
223% \pgfplotstableread[col sep = comma]{data/icgrep-mt-scatter-mt.csv}\mt
224% \pgfplotstableread[col sep = comma]{data/icgrep-mt3-scatter-mt.csv}\mtt
225% \pgfplotstableread[col sep = comma]{data/icgrep-flat-scatter-mt.csv}\flat
226% \begin{tikzpicture}
227% \begin{axis}[
228% grid=both,
229% x tick label style={ /pgf/number format/1000 sep=},
230% ylabel={Seconds Per GB ($1000^3$)},
231% xlabel={Percentage of Matching Lines},
232% minor y tick num={1},
233% ymin=0,ymax=3,
234% xmax=100,
235% height=0.5\textwidth,
236% legend style={at={(1.05,0.5)},
237% anchor=west,legend columns=1,
238% align=left,draw=none,column sep=2ex}
239% ]
240% \addplot+[sharp plot, no markers,line width=2pt,color=blue!60,solid] table {\base};
241% \addplot+[sharp plot, no markers,line width=2pt,color=red!60,solid] table {\mt};
242% \addplot+[sharp plot, no markers,line width=2pt,color=brown!60,solid] table {\mtt};
243% %\addplot+[no markers,line width=2pt,color=green!60,solid] table {\flat};
244% \legend{icGrep (Base),icGrep (MT2),icGrep (MT3), icGrep (Flat)}
245% \end{axis}
246%
247%
248% \end{tikzpicture}
249% \end{center}
250% \caption{Multithreading Performance}\label{fig:performance_test}
251% \end{figure}
Note: See TracBrowser for help on using the repository browser.