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

Last change on this file since 4560 was 4560, checked in by nmedfort, 4 years ago

Edits

File size: 16.8 KB
Line 
1\section{Evaluation}\label{sec:evaluation}
2
3In this section, we report on the evaluation of \icGrep{} performance, looking at three aspects.   
4%
5First, we discuss some performance aspects of \icGrep{} internal methods, looking at the impact of optimizations discussed previously.
6%
7Then we move on to a systematic performance study of \icGrep{} with named Unicode property searches in comparison to two contemporary competitors,
8namely, pcre2grep released in January 2015 and ugrep of the ICU 54.1 software distribution.
9%
10Finally, we examine complex expressions and the impact of multithreading \icGrep{} on an
11Intel i7-2600 (3.4GHz) and i7-4700MQ (2.4GHz) processor.
12
13\subsection{Optimizations of Bitwise Methods}
14
15In order to support evaluation of bitwise methods, as well as to support
16the teaching of those methods and ongoing research, \icGrep{} has an array
17of command-line options.   This makes it straightforward
18to report on certain performance aspects of \icGrep{}, while others require
19special builds. 
20
21For example, the command-line switch \texttt{-disable-matchstar} can be used
22to eliminate the use of the MatchStar operation for handling
23Kleene-* repetition of character classes.   In this case, \icGrep{} substitutes
24a while loop that iteratively extends match results.   
25Surprisingly, this
26does not change performance much in many practical cases.   
27In each block,
28the maximum iteration count is the maximum length run encountered; the
29overall performance is based on the average of these maxima throughout the
30file.   But when search for XML tags using the regular expression
31\verb:<[^!?][^>]*>:, a slowdown of more than 2$\times$ may be found in files
32with many long tags. 
33
34%The {\tt -disable-log2-bounded-repetition} flag allows these
35%effectiveness of the special techniques for bounded repetition of
36%byte classes to be assessed.   A slowdown of 30\% was observed
37%with the searches using the regular expression
38%\verb:(^|[ ])[a-zA-Z]{11,33}([.!? ]|$):, for example.
39
40To control the insertion of if-statements into dynamically
41generated code, the number of pattern elements between each if-test %non-nullable
42can be selected with the {\tt -if-insertion-gap=} option.   
43%
44The default value in \icGrep{} is 3; setting the gap to 100 effectively
45turns off if-insertion. 
46%
47Eliminating if-insertion sometimes improves performance by avoiding the extra if tests and branch mispredictions.
48%
49For patterns with long strings, however, there can be a substantial slowdown.
50
51%; searching for a pattern of length 40 slows down by more
52%than 50\% without the if-statement short-circuiting. %%% I think we'd need to show this always true to make this claim.
53
54\comment{
55Additionally, \icGrep{} provides options that allow
56various internal representations to be printed out.   
57%
58These can aid in understanding and/or debugging performance issues.
59For example, the option
60{\tt -print-REs} shows the parsed regular expression as it goes
61through various transformations.   The internal \Pablo{} code generated
62may be displayed with {\tt -print-pablo}.  This can be quite useful in
63helping understand the match process.   It also possible to print out the
64generated LLVM IR code ({\tt -dump-generated-IR}), but this may be
65less useful as it includes many
66details of low-level carry-handling that obscures the core logic.
67}
68
69The precompiled calculations of the various Unicode properties
70are each placed in if-hierarchies as described previously.   To assess the
71impact of this strategy, we built a version of icGrep without such
72if-hierarchies.  In this case, when a Unicode property class is defined,
73bitwise logic equations are applied for all members of the class independent
74of the Unicode blocks represented in the input document.   For the classes
75covering the largest numbers of codepoints, we observed slowdowns of up to 5$\times$.
76
77\subsection{Simple Property Expressions}
78
79A key feature of Unicode level 1 support in regular expression engines
80the support that they provide for property expressions and combinations of property expressions
81using set union, intersection and difference operators.   Both {\tt ugrep}
82and {\tt icgrep} provide systematic support for all property expressions
83at Unicode Level 1 as well as set union, intersection and difference.
84Unfortunetly, {\tt pcre2grep} does not support the set intersection and difference operators directly.
85However, these operators can be expressed using a regular expression
86feature known as a lookbehind assertion.   Set intersection involves a
87regular expression formed with a one of the property expressions and a
88positive lookbehind assertion on the other, while set difference uses
89a negative lookbehind assertion. 
90
91We generated a set of regular expressions involving all Unicode values of
92the Unicode general category property ({\tt gc}) and all values of the Unicode
93script property ({\tt sc}). 
94We then generated
95expressions involving random pairs of {\tt gc} and {\tt sc}
96values combined with a random set operator chosen from union, intersection and difference.
97All property values are represented at least once.   
98A small number of
99expressions were removed because they involved properties not supported by pcre2grep.
100In the end 246 test expressions were constructed in this process.
101
102\begin{figure}
103\begin{center}
104\pgfplotstableread[col sep = comma]{data/icgrep-scatter.csv}\icgrep
105\pgfplotstableread[col sep = comma]{data/ugrep541-scatter.csv}\ugrep
106\pgfplotstableread[col sep = comma]{data/pcre2grep-scatter.csv}\pcre
107
108\begin{tikzpicture}
109\begin{axis}[
110grid=both,
111x tick label style={ /pgf/number format/1000 sep=},
112ylabel={CPU Cycles Per Byte},
113xlabel={Percentage of Matching Lines},
114minor y tick num={1},
115xmax=100,
116height=0.5\textwidth,
117legend style={at={(1.05,0.5)},
118anchor=west,legend columns=1,
119align=left,draw=none,column sep=2ex}
120]
121\addplot+[no markers,line width=2pt,color=blue!60,solid] table {\icgrep};
122\addplot+[no markers,line width=2pt,color=red!60,solid] table {\ugrep};
123\addplot+[no markers,line width=2pt,color=brown!60,solid] table {\pcre};
124\legend{icGrep,ugrep541,pcre2grep}
125\end{axis}
126
127
128\end{tikzpicture}
129\end{center}
130\caption{Matching Performance for Simple Property Expressions}\label{fig:property_test}
131\end{figure}
132
133We selected a set of Wikimedia XML files in several major languages representing
134most of the world's major language families as a test corpus.
135%
136For each program under test, we performed searches for each regular expression against each XML document.
137%
138Performance is reported in CPU cycles per byte on an Intel i7-2600 machine.   
139%
140The results are presented in Figure~\ref{fig:property_test}.
141%
142They were ranked by the percentage of matching lines found in the XML document and grouped in 5\% increments. 
143%
144When comparing the three programs, \icGrep{} exhibits dramatically better performance, particularly when searching for rare items.
145%
146The performance of both pcre2grep and ugrep improves (has a reduction in CPU cycles per byte) as the percentage of matching lines increases.
147%
148This occurs because each match allows them to bypass processing the rest of the line.
149%
150On the other hand, \icGrep{} shows a slight drop-off in performance with the number of matches found.   
151%
152This is primarily due to property classes that include large numbers of codepoints.   
153%
154These classes require more bitstream equations for calculation and also have a greater probability of matching.   
155%
156Nevertheless, the performance of \icGrep{} in matching the defined property expressions is stable and well ahead of the competitors in all cases.
157
158
159\subsection{Complex Expressions}
160
161\begin{table}\centering % requires booktabs
162\small\vspace{-2em}
163\begin{tabular}{@{}p{2.7cm}p{10.8cm}@{}}
164\textbf{Name}&\textbf{Regular Expression}\\
165\toprule
166Alphanumeric \#1&\verb`^[\p{L}\p{N}]*((\p{L}\p{N})|(\p{N}\p{L}))[\p{L}\p{N}]*$`\\
167\midrule
168Alphanumeric \#2&\verb`[\p{L}\p{N}]*((\p{L}\p{N})|(\p{N}\p{L}))[\p{L}\p{N}]*`\\
169\midrule
170Arabic&\verb`^[\p{Arabic}\p{Common}]*\p{Arabic}[\p{Arabic}\p{Common}]*$`\\
171\midrule
172Currency&\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})`\\
173\midrule
174Cyrillic&\verb`[\p{Pi}\p{Po}]\p{Cyrillic}{6,}[\p{Pf}\p{Pe}]`\\
175\midrule
176Email &\verb`([^\p{Z}<]+@[\p{L}\p{M}\p{N}.-]+\.(\p{L}\p{M}*){2,6})(>|\p{Z}|$)`\\
177\bottomrule
178\end{tabular}
179\caption{Regular Expressions}\label{table:regularexpr}
180\vspace{-2em}
181\end{table}
182
183This study evaluates the comparative performance of the matching engines on a
184series of more complex expressions, shown in Table \ref{table:regularexpr}.
185%
186The first two are alphanumeric expressions, differing only in that the first
187one is anchored to match the entire line.
188%
189The third searches for lines consisting of text in Arabic script.
190%
191The fourth expression is a published currency expression taken from
192Stewart and Uckelman~\cite{stewart2013unicode}.
193%
194An expression matching runs of six or more Cyrillic script characters enclosed
195in initial/opening and final/ending punctuation is fifth in the list.
196%
197The final expression is an email expression that allows internationalized names.
198%
199In Table \ref{table:complexexpr}, we show the performance results obtained
200from an Intel i7-2600 using generic 64-bit binaries for each engine.
201We limit the SIMD ISA within \icGrep{} to SSE2 which is available
202on all Intel/AMD 64-bit machines.
203%
204In each case, we report seconds taken per GB of input averaged over 10 
205runs each on our Wikimedia document collection.
206
207%
208
209% \begin{table}
210% \begin{center}
211% \begin{tabular}{|c|r|r|r|}  \hline
212% Regular & \multicolumn{3}{|c|}{CPU cycles per byte} \\ \cline{2-4}
213% Expression & icGrep{} & pcre2grep & ugrep \\ \hline
214% blah  & 1 & 1000 & 100 \\ \hline
215% \end{tabular}
216% \caption{Matching Times for Complex Expressions}\label{table:complexexpr}
217% \end{center}
218% \end{table}
219
220% \begin{table*}[htbp]
221% \begin{center}
222% \footnotesize
223% \begin{tabular}{|l||l|l|}
224% \hline
225% Processor & i7-2600 (3.4GHz) & i7-4700MQ (2.4GHz) \\ \hline
226% L1 Cache & 256KB & 256KB  \\ \hline       
227% L2 Cache & 1MB & 1MB  \\ \hline
228% L3 Cache & 8MB & 8MB \\ \hline
229% Bus & 1333Mhz & 1600Mhz \\ \hline
230% Memory & 8GB & 8GB \\ \hline
231% \end{tabular}
232% \caption{Platform Hardware Specs}
233% \label{hwinfo}
234% \end{center}
235% \vspace{-20pt}
236% \end{table*}
237
238\begin{table}[ht]\centering % requires booktabs
239\newcolumntype{T}{c}
240\small\vspace{-2em}
241\begin{tabular}{@{}p{3cm}r@{~--~}rp{4pt}r@{~--~}rp{4pt}r@{~--~}rp{4pt}r@{~--~}rp{4pt}@{}}
242&\multicolumn{6}{c}{\textbf{\icGrep{} (SSE2)}}\\
243\cmidrule[1pt](lr){2-7}
244\cmidrule[1pt](lr){8-10}
245\cmidrule[1pt](lr){11-13}
246\textbf{Expression}&\multicolumn{3}{T}{\textbf{SEQ}}&\multicolumn{3}{T}{\textbf{MT}}&\multicolumn{3}{T}{\textbf{pcre2grep}}&\multicolumn{3}{T}{\textbf{ugrep541}}\\
247\toprule
248Alphanumeric \#1&2.4&5.0&&2.1&4.4&&8.2&11.3&&8.8&11.3&\\
249Alphanumeric \#2&2.3&4.9&&2.0&4.1&&209.9&563.5&&182.3&457.9&\\
250Arabic&1.5&3.4&&1.2&2.6&&7.5&270.8&&8.9&327.8&\\
251Currency&0.7&2.1&&0.4&1.4&&188.4&352.3&&52.8&152.8&\\
252Cyrillic&1.6&3.9&&1.3&2.8&&30.5&49.7&&11.2&20.1&\\
253Email&3.0&6.9&&2.7&6.4&&67.2&1442.0&&108.8&1022.3&\\
254\bottomrule
255\end{tabular}
256\caption{Matching Times for Complex Expressions (Seconds Per GB)}\label{table:complexexpr}
257\vspace{-2em}
258\end{table}
259
260
261The most striking aspect of Table \ref{table:complexexpr} is that both ugrep and pcregrep
262show dramatic slowdowns with ambiguities in regular expressions.
263%
264This is most clearly illustrated in the different performance figures
265for the two Alphanumeric test expressions but is also evident in the
266Arabic, Currency and Email expressions.   
267%
268Contrastingly, \icGrep{} maintains consistently fast performance in all test scenarios. 
269%
270The multithreaded \icGrep{} shows speedup in every case but balancing
271of the workload across multiple cores is clearly an area for further work.
272%
273Nevertheless, our three-thread system shows up to a 40\% speedup. %  over the single threaded version
274
275
276
277%
278Table \ref{table:relperf} shows the speedups obtained with \icGrep{}
279on a newer Intel i7-4700MQ machine, considering three SIMD ISA alternatives
280and both single-threaded and multi-threaded versions.
281All speedups are relative to the base single-threaded SSE2 performance on the i7-2600 machine.
282%
283The SSE2 results are again using the generic binaries compiled for compatibility
284with all 64-bit processors.   
285%
286The AVX1 results are for Intel AVX instructions
287in 128-bit mode.  The main advantage of AVX1 over SSE2 is its support for 3-operand form,
288which helps reduce register pressure.   The AVX2 results are for \icGrep{}
289compiled to use the 256-bit AVX2 instructions, processing blocks of 256 bytes at a time.
290
291
292
293% \begin{table}[h]\centering % requires booktabs,siunitx
294% \small
295% \vspace{-2em}
296% \begin{tabular}{@{}p{3cm}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}@{}}
297% &\multicolumn{6}{c}{\textbf{SEQ}}&\multicolumn{6}{c}{\textbf{MT}}\\
298% \cmidrule[1pt](lr){2-7}
299% \cmidrule[1pt](lr){8-13}
300% \textbf{Expression}&\multicolumn{2}{c}{\textbf{SSE2}}&\multicolumn{2}{c}{\textbf{AVX1}}&\multicolumn{2}{c}{\textbf{AVX2}}&\multicolumn{2}{c}{\textbf{SSE2}}&\multicolumn{2}{c}{\textbf{AVX1}}&\multicolumn{2}{c}{\textbf{AVX2}}\\
301% \toprule
302% Alphanumeric \#1&1.28&(.06)&1.35&(.05)&1.64&(.16)&1.41&(.06)&1.44&(.06)&1.96&(.18)\\
303% Alphanumeric \#2&1.27&(.06)&1.32&(.05)&1.77&(.19)&1.39&(.07)&1.39&(.04)&2.18&(.22)\\
304% Arabic&1.21&(.07)&1.28&(.08)&1.43&(.16)&1.30&(.05)&1.30&(.05)&1.63&(.13)\\
305% Currency&1.01&(.05)&1.03&(.06)&1.06&(.12)&1.05&(.05)&1.06&(.05)&1.21&(.08)\\
306% Cyrillic&1.18&(.06)&1.25&(.05)&1.13&(.10)&1.26&(.04)&1.33&(.04)&1.22&(.10)\\
307% Email&1.32&(.04)&1.38&(.05)&1.86&(.21)&1.42&(.04)&1.46&(.05)&2.17&(.26)\\
308% \midrule
309% \textit{Geomean}&1.21&&1.26&&1.45&&1.30&&1.32&&1.68&\\
310% \bottomrule
311% \end{tabular}
312% \caption{Speedups of Complex Expressions for i7-2600 / i7-4700MQ $(\sigma)$}\label{table:relperf}
313% \vspace{-2em}
314% \end{table}
315
316\begin{table}[h]\centering % requires booktabs,siunitx
317\small
318\vspace{-2em}
319\begin{tabular}{@{}p{3cm}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}l@{~}r@{~~}@{}}
320&\multicolumn{2}{c}{\textbf{Base}}&\multicolumn{4}{c}{\textbf{SEQ}}&\multicolumn{6}{c}{\textbf{MT}}\\
321\cmidrule[1pt](lr){2-3}
322\cmidrule[1pt](lr){4-7}
323\cmidrule[1pt](lr){8-13}
324\textbf{Expression}&\multicolumn{2}{c}{\textbf{s/GB}}&\multicolumn{2}{c}{\textbf{AVX1}}&\multicolumn{2}{c}{\textbf{AVX2}}&\multicolumn{2}{c}{\textbf{SSE2}}&\multicolumn{2}{c}{\textbf{AVX1}}&\multicolumn{2}{c}{\textbf{AVX2}}\\
325\toprule
326Alphanumeric \#1&2.76&(.65)&1.05&(.03)&1.25&(.08)&1.18&(.02)&1.19&(.03)&1.59&(.10)\\
327Alphanumeric \#2&2.69&(.66)&1.05&(.02)&1.36&(.09)&1.20&(.03)&1.19&(.04)&1.80&(.11)\\
328Arabic&1.82&(.39)&1.05&(.03)&1.15&(.08)&1.37&(.03)&1.37&(.04)&1.66&(.10)\\
329Currency&1.04&(.30)&1.03&(.02)&1.04&(.06)&1.59&(.15)&1.61&(.14)&1.78&(.21)\\
330Cyrillic&2.10&(.44)&1.06&(.02)&0.96&(.06)&1.27&(.02)&1.33&(.04)&1.23&(.09)\\
331Email&3.57&(.87)&1.05&(.03)&1.37&(.14)&1.13&(.03)&1.16&(.04)&1.67&(.18)\\
332\midrule
333\textit{Geomean}&\multicolumn{2}{c}{--}&1.04&&1.18&&1.28&&1.30&&1.61&\\
334\bottomrule
335\end{tabular}
336\caption{Speedups of Complex Expressions for i7-2600 / i7-4700MQ $(\sigma)$}\label{table:relperf}
337\vspace{-2em}
338\end{table}
339
340
341% Interestingly, the SSE2 column of Table \ref{table:relperf} shows that by simply using a newer hardware and compiler
342% improves performance by $21\%$ and $30\%$ for the sequential and multithreaded versions of \icGrep{}.
343% %
344% By taking advantage of the improved AVX1 and AVX2 ISA there are further improvements but AVX2 exhibits
345% higher variation between datasets.
346% %
347% This appears to be a consequence of complex Kleene-* repetitions (i.e., those that cannot utilize the MatchStar operation)
348% both resulting in increased register pressure and worse branch misprediction because of the characteristics in the datasets
349% themselves.
350% %
351%
352
353
354
355
356
357
358
359
360
361
362% \subsection{Single vs. Multithreaded Performance}
363%
364%
365% \begin{figure}
366% \begin{center}
367% \pgfplotstableread[col sep = comma]{data/icgrep-scatter-mt.csv}\base
368% \pgfplotstableread[col sep = comma]{data/icgrep-mt-scatter-mt.csv}\mt
369% \pgfplotstableread[col sep = comma]{data/icgrep-mt3-scatter-mt.csv}\mtt
370% \pgfplotstableread[col sep = comma]{data/icgrep-flat-scatter-mt.csv}\flat
371% \begin{tikzpicture}
372% \begin{axis}[
373% grid=both,
374% x tick label style={ /pgf/number format/1000 sep=},
375% ylabel={Seconds Per GB ($1000^3$)},
376% xlabel={Percentage of Matching Lines},
377% minor y tick num={1},
378% ymin=0,ymax=3,
379% xmax=100,
380% height=0.5\textwidth,
381% legend style={at={(1.05,0.5)},
382% anchor=west,legend columns=1,
383% align=left,draw=none,column sep=2ex}
384% ]
385% \addplot+[sharp plot, no markers,line width=2pt,color=blue!60,solid] table {\base};
386% \addplot+[sharp plot, no markers,line width=2pt,color=red!60,solid] table {\mt};
387% \addplot+[sharp plot, no markers,line width=2pt,color=brown!60,solid] table {\mtt};
388% %\addplot+[no markers,line width=2pt,color=green!60,solid] table {\flat};
389% \legend{icGrep (Base),icGrep (MT2),icGrep (MT3), icGrep (Flat)}
390% \end{axis}
391%
392%
393% \end{tikzpicture}
394% \end{center}
395% \caption{Multithreading Performance}\label{fig:performance_test}
396% \end{figure}
Note: See TracBrowser for help on using the repository browser.