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

Last change on this file since 4558 was 4558, checked in by cameron, 4 years ago

streamlining

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