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

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

Multithreading figure + data

File size: 8.4 KB
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.
11\subsection{ICgrep vs. Contemporary Competitors}
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.  As all three programs support lookbehind
24assertions in this way, we systematically generated set intersection and
25difference in this way.
27We generated a set of regular expressions involving all Unicode values of
28the Unicode general
29category property ({\tt gc}) and all values of the Unicode script property ({\tt sc}).  We then generated
30expressions involving random pairs of {\tt gc} and {\tt sc}
31values combined with a random set operator chosen from union, intersection and difference.
32All property values are represented at least once.   A 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.
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.
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
65x tick label style={ /pgf/number format/1000 sep=},
66ylabel={CPU Cycles Per Byte},
67xlabel={Percentage of Matching Lines},
68minor y tick num={1},
71legend style={at={(1.05,0.5)},
72anchor=west,legend columns=1,
73align=left,draw=none,column sep=2ex}
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};
84\caption{Comparative Matching Performance}\label{fig:property_test}
88\subsection{Optimizations of Bitwise Methods}
90In order to support evaluation of bitwise methods, as well as to support
91the teaching of those methods and ongoing research, \icGrep{} has an array
92of command-line options.   This makes it relatively straightforward
93to report on certain performance aspects of ICgrep, while others require
94special builds. 
96For example, the command-line switch {\tt -disable-matchstar} can be used
97to eliminate the use of the MatchStar operation for handling
98Kleene-* repetition of character classes.   In this case, \icGrep{} substitutes
99a while loop that iteratively extends match results.   
100Surprisingly, this
101does not change performance much in many practical cases.   
102In each block,
103the maximum iteration count is the maximum length run encountered; the
104overall performance is based on the average of these maximums throughout the
105file.   But when search for XML tags using the regular expression
106\verb:<[^!?][^>]*>:, a slowdown of more than 2X may be found in files
107with many long tags. 
109The {\tt -disable-log2-bounded-repetition} flag allows these
110effectiveness of the special techniques for bounded repetition of
111byte classes to be assessed.   A slowdown of 30\% was observed
112with the searches using the regular expression
113\verb:(^|[ ])[a-zA-Z]{11,33}([.!? ]|$):, for example.
115To assess the effectiveness of inserting if-statements, the
116number of non-nullable pattern elements between the if-tests
117can be set with the {\tt -if-insertion-gap=} option.   The
118default value in \icGrep{} is 3, setting the gap to 100 effectively
119turns of if-insertion.   Eliminating if-insertion sometimes improves
120performance by avoiding the extra if tests and branch mispredications.
121For patterns with long strings, however, there can be a substantial
122slowdown; searching for a pattern of length 40 slows down by more
123than 50\% without the if-statement short-circuiting.
125ICgrep also provides options that allow
126various internal representations to be printed out.   These
127can aid in understanding and/or debugging performance issues.
128For example, the option
129{\tt -print-REs} show the parsed regular expression as it goes
130through various transformations.   The internal Pablo code generated
131may be displayed with {\tt -print-pablo}.  This can be quite useful in
132helping understand the match process.   It also possible to print out the
133generated LLVM IR code ({\tt -dump-generated-IR}), but this may be
134less useful as it includes many
135details of low-level carry-handling that obscures the core logic.
137The precompiled calculations of the various Unicode properties
138are each placed in if-hierarchies as described previously.   To assess the
139impact of this strategy, we built a version of icGrep without such
140if-hierarchies.  In this case, when a Unicode property class is defined,
141bitwise logic equations are applied for all members of the class independent
142of the Unicode blocks represented in the input document.   For the classes
143covering the largest numbers of codepoints, we observed slowdowns of up to 5X.
147\subsection{Single vs. Multithreaded Performance}
152\pgfplotstableread[col sep = comma]{data/icgrep-scatter-mt.csv}\base
153\pgfplotstableread[col sep = comma]{data/icgrep-mt-scatter-mt.csv}\mt
154\pgfplotstableread[col sep = comma]{data/icgrep-mt3-scatter-mt.csv}\mtt
155\pgfplotstableread[col sep = comma]{data/icgrep-flat-scatter-mt.csv}\flat
159x tick label style={ /pgf/number format/1000 sep=},
160ylabel={Seconds Per GB ($1000^3$)},
161xlabel={Percentage of Matching Lines},
162minor y tick num={1},
166legend style={at={(1.05,0.5)},
167anchor=west,legend columns=1,
168align=left,draw=none,column sep=2ex}
170\addplot+[sharp plot, no markers,line width=2pt,color=blue!60,solid] table {\base};
171\addplot+[sharp plot, no markers,line width=2pt,color=red!60,solid] table {\mt};
172\addplot+[sharp plot, no markers,line width=2pt,color=brown!60,solid] table {\mtt};
173%\addplot+[no markers,line width=2pt,color=green!60,solid] table {\flat};
174\legend{icGrep (Base),icGrep (MT2),icGrep (MT3), icGrep (Flat)}
180\caption{Multithreading Performance}\label{fig:performance_test}
Note: See TracBrowser for help on using the repository browser.