You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: bench.tex
+31-34Lines changed: 31 additions & 34 deletions
Original file line number
Diff line number
Diff line change
@@ -4,13 +4,13 @@ \section{Benchmarks}
4
4
% Remove indentation on all itemize lists.
5
5
\setlist[itemize]{leftmargin=*}
6
6
7
-
We now compare the performances of our implementations in two dimensions:
7
+
We consider the performance of our implementations in two dimensions:
8
8
first the successive algorithmic refinements in the \haskell
9
9
implementation presented in \cref{sec:gener-cross-sect,sec:improvements},
10
-
then the various segments representations in \ocaml
10
+
then the various segment representations in \ocaml
11
11
as described in \cref{sec:ocaml}.
12
12
13
-
Benchmarks were done on a ThinkPad T470 with an i5-7200U CPU and 12G of memory.
13
+
Benchmarks were executed on a ThinkPad T470 with an i5-7200U CPU and 12G of memory.
14
14
The \haskell benchmarks use the Stackage LTS 10.8 release and the \texttt{-O2} option.
15
15
The OCaml benchmarks use \ocaml 4.06.1 with the flambda optimizer and the
16
16
\texttt{-O3} option.
@@ -20,14 +20,13 @@ \section{Benchmarks}
20
20
21
21
\subsection{Comparing Algorithms in the \haskell Implementation}
22
22
23
-
\cref{sec:gener-cross-sect,sec:improvements} develop the
24
-
algorithm for generating languages in a sequence of changes applied to
25
-
a naive baseline algorithm. We now evaluate the impact of these
26
-
changes on performance, which we plan to measure in terms of
27
-
generation speed in words per second. It turns out that this speed
28
-
depends heavily on the characteristics of the the regular expression
29
-
considered. We thus choose three representative regular expressions to highlight the
30
-
strengths and weaknesses of the different approaches.
23
+
\cref{sec:gener-cross-sect,sec:improvements} develop the algorithm for
24
+
generating languages in a sequence of changes applied to a baseline
25
+
algorithm. We evaluate the impact of these changes on performance by
26
+
measuring the generation speed in words per second. This speed depends
27
+
heavily on the particular regular expression. Thus, we select four
28
+
representative regular expressions to highlight the strengths and
29
+
weaknesses of the different approaches.
31
30
\begin{itemize}
32
31
\item$\Rstar a$: This expression describes a very small language with $P (w\in L) = 0$.
33
32
Nevertheless, it puts a lot of stress on the underlying
@@ -36,7 +35,7 @@ \subsection{Comparing Algorithms in the \haskell Implementation}
36
35
the output language contain exactly one element. This combination
37
36
highlights the usefulness of sparse indexing and maps.
38
37
\item$\Rstar{(\Rconcat{a}{\Rstar{b}})}$: On the opposite end of the
39
-
spectrum, the language of this regular expression is fairly large
38
+
spectrum, the language of this regular expression is large
40
39
with $P (w\in L)=0.5$. The expression applies \code{star} to a
41
40
language where segment $n+1$ consists of the word $ab^n$. Its
42
41
evaluation measures the performance of \code{star} on a non-sparse
@@ -60,10 +59,9 @@ \subsection{Comparing Algorithms in the \haskell Implementation}
60
59
\label{bench:haskell:all}
61
60
\end{figure}
62
61
63
-
In the evaluation, we consider five variants of the Haskell implementation.
62
+
We consider five variants of the Haskell implementation.
64
63
\begin{itemize}
65
-
\item\textbf{McIlroy} is our implementation of
66
-
the algorithm by \citet{DBLP:journals/jfp/McIlroy99}.
64
+
\item\textbf{McIlroy} our implementation of \citet{DBLP:journals/jfp/McIlroy99}.
67
65
\item The \textbf{seg} implementation uses the infinite list-based segmented
68
66
representation throughout (\cref{sec:segm-repr}).
69
67
\item The \textbf{segConv} implementation additionally
@@ -75,12 +73,11 @@ \subsection{Comparing Algorithms in the \haskell Implementation}
75
73
symbolic segments (\cref{sec:segm-repr,sec:more-finite-repr}) with the convolution approach.
76
74
\end{itemize}
77
75
78
-
Performances are evaluated by iterating through the stream of words
76
+
Performance is evaluated by iterating through the stream of words
79
77
produced by the generator, forcing their evaluation\footnote{In
80
78
Haskell, forcing is done using \lstinline{Control.DeepSeq}.}
81
-
and recording the elapsed timed every 20 words.
82
-
We stop the iteration after 5 seconds.
83
-
The resulting graph plots the time (x-axis) against the number of words (y-axis) produced so far. The slope of the graph indicates the generation speed of the plotted algorithm, high slope is correlated to high generation speed. \cref{bench:haskell:all} contains the results for the Haskell implementations.
79
+
and recording the elapsed timed every 20 words for 5 seconds.
80
+
The resulting graph plots the time (x-axis) against the number of words (y-axis) produced so far. The slope of the graph indicates the generation speed of the algorithm, high slope is correlated to high generation speed. \cref{bench:haskell:all} contains the results for the Haskell implementations.
84
81
85
82
Most algorithms generate between $1.3\cdot10^3$ and $1.4\cdot10^6$ words in the first
86
83
second, which seems sufficient for testing purposes.
@@ -97,15 +94,14 @@ \subsection{Comparing Algorithms in the \haskell Implementation}
97
94
remarks:
98
95
\begin{itemize}[leftmargin=*]
99
96
\item All implementations are equally fast on $\Rstar a$ except
100
-
\textbf{McIlroy}, which relies on list lookups without
101
-
sparse indexing.
97
+
\textbf{McIlroy}, which implements star inefficiently.
102
98
\item The graph of some implementations
103
99
has the shape of ``skewed stairs''. We believe this phenomenon is due to
104
100
insufficient laziness: when arriving at a new segment, part of the
105
101
work is done eagerly which causes a plateau. When that part is done,
106
102
the enumeration proceeds lazily. As laziness and GHC
107
103
optimizations are hard to control, we did not attempt to correct this.
108
-
\item$\Rstar{(\Rconcat{a}{\Rstar{b}})}$ demonstrates that
104
+
\itemThe expression $\Rstar{(\Rconcat{a}{\Rstar{b}})}$ demonstrates that
109
105
the convolution technique presented in \cref{sec:convolution}
110
106
leads to significant improvements when applying \code{star} to non-sparse languages.
111
107
\item The \textbf{refConv} algorithm is
@@ -117,9 +113,10 @@ \subsection{Comparing Algorithms in the \haskell Implementation}
117
113
is $\Lang{b}$, which is also represented finitely by
118
114
\textbf{segConv} and should thus benefit from the convolution
119
115
improvement in the same way as \textbf{refConv}.
120
-
\item$\Rstar{(\Rconcat{a}{\Rstar{b}})}$ shows that all our algorithm have similar
121
-
performance profiles on set-operation. They are also significantly
122
-
faster than \textbf{McIlroy}.
116
+
\item The expression $\Rintersect{\Rcomplement{(\Rstar{a})}}{\Rcomplement{(\Rstar{b})}}$
117
+
shows that all our algorithm have similar performance profiles on
118
+
set-operation. They are also significantly faster than
119
+
\textbf{McIlroy}.
123
120
\end{itemize}
124
121
125
122
@@ -135,9 +132,9 @@ \subsection{Comparing Data Structures in the \ocaml Implementation}
135
132
136
133
We have now established that the \textbf{refConv} algorithm
137
134
provides the best overall performance. The \haskell implementation,
138
-
however, only uses lazy lists to represent segments.
135
+
however, uses lazy lists to represent segments.
139
136
To measure the influence of strictness and data structures on
140
-
performances, we consider the functorized \ocaml implementation, as it facilitates such experimentation.
137
+
performances, we conduct experiments with the functorized \ocaml implementation.
141
138
We follow the same methodology as the \haskell evaluation using the
142
139
regular expressions $\Rstar a$, $\Rstar{(\Rconcat{a}{\Rstar{b}})}$ and
143
140
$\Rconcat{\Rcomplement{(\Rstar{a})}}{b}$. The results are shown in
@@ -147,15 +144,15 @@ \subsection{Comparing Data Structures in the \ocaml Implementation}
147
144
among the data structures.
148
145
Lazy and Thunk lists, with or without memoizations, are the most ``well-rounded''
149
146
implementations and perform decently on most languages.
150
-
We can however make the following remarks.
147
+
%We can however make the following remarks.
151
148
\begin{itemize}[leftmargin=*]
152
149
\item The \code{Trie} module
153
150
is very fast thanks to its efficient concatenation.
154
-
It however performs badly on $\Rstar a$
151
+
It performs badly on $\Rstar a$
155
152
due to the lack of path compression:
156
153
in the case of $\Rstar a$, where each segment contains only one word, the
157
154
trie degenerates to a list of characters.
158
-
We believe an implementation of tries with path compressions would perform
155
+
We believe an implementation of tries with path compression would perform
159
156
significantly better.
160
157
\item The other data structures exhibit a very pronounced slowdown on $\Rstar a$
161
158
when reaching 150000 words.
@@ -168,11 +165,11 @@ \subsection{Comparing Data Structures in the \ocaml Implementation}
168
165
\ocaml. These results also demonstrate that strict data structures
169
166
should only be used when all elements up to a given length are
170
167
needed. In such a case the stair pattern causes no problems.
171
-
\item Memoization for thunk lists does not significantly increase performances.
168
+
\item Memoization for thunk lists does not significantly improve performance.
172
169
It seems that the linear cost of memoizing the thunk list and
173
170
allocating the vectors
174
-
is often higher than simply recomputing lists.
175
-
\item$\Rstar{(\Rconcat{a}{\Rstar{b}})}$ shows that sorted enumerations and tries
171
+
is often higher than simply recomputing the lists.
172
+
\itemThe expression $\Rstar{(\Rconcat{a}{\Rstar{b}})}$ shows that sorted enumerations and tries
176
173
perform well on set-operations, even compared to strict sets.
177
174
\end{itemize}
178
175
@@ -193,7 +190,7 @@ \subsection{The Influence of Regular Expressions on Performance}
193
190
Before presenting the results, a word of warning:
194
191
We do not claim to offer a fair comparison between languages!
195
192
The two implementations are not exactly the same and we made no attempt
196
-
to measure both language under exactly the same conditions.
193
+
to measure both languages under exactly the same conditions.
197
194
%
198
195
\cref{bench:langs} contains the results with a
199
196
logarithmic scale for the word count as it enables better comparison
0 commit comments