source: docs/Working/re/sse2.tex @ 3510

Last change on this file since 3510 was 3510, checked in by bhull, 6 years ago

Chart changes.

File size: 7.8 KB
Line 
1\section{SSE2 Implementation and Evaluation}\label{sec:SSE2}
2
3\paragraph{Implementation Notes.}
4Our regular expression compiler directly uses the Parabix tool chain
5to compile regular expression into SSE2-based implementations.
6Our compiler essentially scripts three other compilers to perform
7this work: the Parabix character class compiler to determine basic
8bit stream equations for each of the character classes encountered
9in a regular expression, the Pablo bitstream equation compiler which
10converts equations to block-at-a-time C++ code for 128-bit SIMD, and
11gcc 4.6.3 to generate the binaries.   The Pablo output is combined
12with a {\tt grep\_template.cpp} file that arranges to read input
13files, break them into segments, and print out or count matches
14as they are encountered.
15
16\paragraph{Comparative Implementations.}
17We evaluate our bitwise data parallel implementation versus several alternatives.   We report data for two of these: GNU grep version 2.10
18and nrgrep version 1.12. GNU grep is a popular open-source grep implementation that uses DFAs,
19as well as heuristics for important special cases.
20The NFA class is represented by nrgrep, one of the
21strongest competitors in regular expression matching performance.
22We also considered agrep 3.41 as and alternative NFA-based implementation
23and pcregrep 8.12 as a backtracking implementation, but do not
24report data for them.  The agrep implementation does not support
25some of the common regular expression syntax feature and is limited to
26patterns of at most 32 characters.   As a backtracking implementation,
27pcregrep supports more regular expression features, but is not
28competitive in performance in any example we tested.
29
30We performed our SSE2 performance study using an Intel Core i7 quad-core (Sandy Bridge) processor (3.40GHz, 4 physical cores, 8 threads (2 per core), 32+32 kB (per core) L1 cache, 256 kB (per core) L2 cache, 8 MB L3 cache) running the 64-bit version of Ubuntu 12.04 (Linux).
31
32\begin{table*}[htbp]
33\begin{center}
34{
35\footnotesize
36\begin{tabular}{|l|l|}
37\hline
38Name            & Expression    \\ \hline   
39@               & \verb`@`              \\ \hline     
40Date            & \verb`([0-9][0-9]?)/([0-9][0-9]?)/([0-9][0-9]([0-9][0-9])?)`          \\ \hline     
41Email           & \verb`([^ @]+)@([^ @]+)`              \\ \hline
42URIOrEmail      & \verb`([a-zA-Z][a-zA-Z0-9]*)://([^ /]+)(/[^ ]*)?|([^ @]+)@([^ @]+)`           \\ \hline     
43Xquote          & \verb`["']|"|'|&#0*3[49];|&#x0*2[27];`              \\ \hline
44\end{tabular}
45}
46\end{center}
47\caption{Regular Expressions}
48\label{RegularExpressions}
49\end{table*}
50
51
52\paragraph{Test expressions.}
53Each grep implementation is tested with the five regular expressions in Table \ref{RegularExpressions}.  Xquote matches any of the representations of a
54single or double quote character occuring in XML content.  It is run on roads-2.gml, a 11,861,751 byte gml data file. The other four expressions are taken from Benchmark of Regex Libraries [http://lh3lh3.users.sourceforge.net/reb.shtml] and are all run on a concatenated version of the linux howto which is 39,422,105 bytes in length.  @ simply matches the "@" character.  It demonstrates the overhead involved in matching the simplest regular expression.  Date, Email, and URIOrEmail provide examples of common uses for regular expression matching.
55
56
57\paragraph{Results.}
58\begin{figure}
59\begin{center}
60\begin{tikzpicture}
61\begin{axis}[
62xtick=data,
63ylabel=Cycles per Byte,
64xticklabels={@,Date,Email,URIorEmail,xquote},
65tick label style={font=\tiny},
66enlarge x limits=0.15,
67enlarge y limits={0.15, upper},
68ymin=0,
69legend style={at={(0.5,-0.15)},
70anchor=north,legend columns=-1},
71ymax=12,
72ybar,
73bar width=7pt,
74visualization depends on=y \as \rawy,
75]
76\addplot
77file {data/cycles1.dat};
78\addplot
79file {data/cycles2.dat};
80\addplot
81file {data/cycles3.dat};
82 
83\legend{Bitstreams,NRGrep,Grep,Annot}
84\end{axis}
85\end{tikzpicture}
86\end{center}
87\caption{Cycles per Byte}\label{fig:SSECyclesPerByte}
88\end{figure}
89
90Figure \ref{fig:SSECyclesPerByte} shows CPU cycles per input byte for each expression on each implementation.
91For the three most complicated expressions, the bitstreams implementation had the lowest cycle count, while grep
92was an order of magnitude slower.
93
94For the @ expression, GNU grep had very slightly better performance than the bitstreams implementation.  The bitstreams implementation has a fixed overhead
95for transposition that hurts relative performance for very simple expressions.
96
97For the Date expression, nrgrep is able to skip large portions of the input file since every time it encounters a character that can't appear in a date, it can skip past six characters.  For the more compicated expressions, it loses this advantage.
98
99The bitstreams implementation has fairly consistent performance.  As the regular expression complexity increases, the cycle count increases slowly.  The largest difference in cycles per byte for the bitstreams implementation is a ratio of 2 to 1.  The same cannot be said of grep or nrgrep.  The
100latter uses more than 10 times the cycles per byte for Xquote than for Date.  The number of cycles per byte that gGrep uses for URIOrEmail is almost 900 times as many as it uses for @.
101
102\begin{figure}
103\begin{center}
104\begin{tikzpicture}
105\begin{axis}[
106xtick=data,
107ylabel=Instructions per Byte,
108xticklabels={@,Date,Email,URIorEmail,xquote},
109tick label style={font=\tiny},
110enlarge x limits=0.15,
111enlarge y limits={0.15, upper},
112ymin=0,
113legend style={at={(0.5,-0.15)},
114anchor=north,legend columns=-1},
115ymax=25,
116ybar,
117bar width=7pt,
118]
119\addplot
120file {data/instructions1.dat};
121\addplot
122file {data/instructions2.dat};
123\addplot
124file {data/instructions3.dat};
125 
126\legend{Bitstreams,NRGrep,Grep,Annot}
127\end{axis}
128\end{tikzpicture}
129\end{center}
130\caption{Instructions per Byte}\label{fig:SSEInstructionsPerByte}
131\end{figure}
132
133Figure \ref{fig:SSEInstructionsPerByte} shows instructions per byte.  The relative values mirror cycles per byte.  The bitstreams implementation continues to show consistent performance.  This is especially noticeable in Figure \ref{fig:SSEInstructionsPerCycle}, which shows instructions per cycle.  The bitstreams implementation has almost no variation in the instructions per cycle.  Both grep and nrGrep have considerably more variation based on the input regular expression.
134 
135
136\begin{figure}
137\begin{center}
138\begin{tikzpicture}
139\begin{axis}[
140xtick=data,
141ylabel=Instructions per Cycle,
142xticklabels={@,Date,Email,URIorEmail,xquote},
143tick label style={font=\tiny},
144enlarge x limits=0.15,
145enlarge y limits={0.15, upper},
146ymin=0,
147legend style={at={(0.5,-0.15)},
148anchor=north,legend columns=-1},
149ybar,
150bar width=7pt,
151]
152\addplot
153file {data/ipc1.dat};
154\addplot
155file {data/ipc2.dat};
156\addplot
157file {data/ipc3.dat};
158
159\legend{Bitstreams,NRGrep,Grep,Annot}
160\end{axis}
161\end{tikzpicture}
162\end{center}
163\caption{Instructions per Cycle}\label{fig:SSEInstructionsPerCycle}
164\end{figure}
165
166\begin{figure}
167\begin{center}
168\begin{tikzpicture}
169\begin{axis}[
170xtick=data,
171ylabel=Branch Misses per Instruction,
172xticklabels={@,Date,Email,URIorEmail,xquote},
173tick label style={font=\tiny},
174enlarge x limits=0.15,
175enlarge y limits={0.15, upper},
176ymin=0,
177legend style={at={(0.5,-0.15)},
178anchor=north,legend columns=-1},
179ybar,
180bar width=7pt,
181]
182\addplot
183file {data/branch-misses1.dat};
184\addplot
185file {data/branch-misses2.dat};
186\addplot
187file {data/branch-misses3.dat};
188
189\legend{Bitstreams,NRGrep,Grep,Annot}
190\end{axis}
191\end{tikzpicture}
192\end{center}
193\caption{Branch Misses per Instruction}\label{fig:SSEBranchMisses}
194\end{figure}
195Figure \ref{fig:SSEBranchMisses} shows the branch misses per kilobyte.  The bitstreams implementation remains consistent here.  Each of nrgrep and grep have branch miss rates that vary significantly with different regular expressions. 
196
197Overall, our performance is considerably better than both nrgrep and grep for the more complicated expressions that were tested.  Also, our performance scales smoothly with regular expression complexity so it can be expected to remain better for complicated expressions in general.
198
199
Note: See TracBrowser for help on using the repository browser.