Skip to content
This repository was archived by the owner on Jun 26, 2023. It is now read-only.

Commit e29802d

Browse files
authored
Wrap up performance evaluation (#122)
* memory consumption profiling for 10e6 x 10 case * Added elapsed time and memory consumption measurements * address of comments
1 parent 736947e commit e29802d

5 files changed

Lines changed: 183 additions & 20 deletions

File tree

executable-spec/bench/micro-benchmarking/Main.hs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@ main :: IO ()
1313
main = do
1414
let
1515
!tallyData2 =
16-
createTallyData constants (NumberOfParticipants 10) (NumberOfConcurrentUPs 10)
16+
createTallyData constants (NumberOfParticipants 100) (NumberOfConcurrentUPs 1)
1717
!tallyData3 =
18-
createTallyData constants (NumberOfParticipants 100) (NumberOfConcurrentUPs 10)
18+
createTallyData constants (NumberOfParticipants 1000) (NumberOfConcurrentUPs 1)
1919
!tallyData4 =
20-
createTallyData constants (NumberOfParticipants 1000) (NumberOfConcurrentUPs 10)
20+
createTallyData constants (NumberOfParticipants 10000) (NumberOfConcurrentUPs 1)
2121
!tallyData5 =
22-
createTallyData constants (NumberOfParticipants 10000) (NumberOfConcurrentUPs 10)
22+
createTallyData constants (NumberOfParticipants 100000) (NumberOfConcurrentUPs 1)
2323
!tallyData6 =
24-
createTallyData constants (NumberOfParticipants 100000) (NumberOfConcurrentUPs 10)
24+
createTallyData constants (NumberOfParticipants 1000000) (NumberOfConcurrentUPs 1)
2525
!tallyData7 =
26-
createTallyData constants (NumberOfParticipants 1000000) (NumberOfConcurrentUPs 10)
27-
print $ runTally constants tallyData3
26+
createTallyData constants (NumberOfParticipants 10000000) (NumberOfConcurrentUPs 1)
27+
print $ runTally constants tallyData2
2828
Cr.defaultMain
2929
[ Cr.bgroup "tally" [ Cr.bench "1e2" $ Cr.whnf allApproved tallyData2
3030
, Cr.bench "1e3" $ Cr.whnf allApproved tallyData3

formal-spec/decentralized-updates.tex

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
\usepackage{pgfplots}
3030
\usepackage{tikz}
3131
\usepackage{tikz}
32+
\usepackage{hyperref}
3233
\usetikzlibrary{arrows,automata, decorations.pathreplacing, positioning, arrows.meta, calc, shapes}
3334
% For drawing simple diagrams involving arrows between LaTeX symbols
3435
\usepackage{tikz-cd}
@@ -50,6 +51,28 @@
5051

5152
\newcommand{\nnote}[1]{{\color{blue}\small Nikos: #1}}
5253

54+
55+
\lstdefinestyle{mystyle}{
56+
% backgroundcolor=\color{backcolour},
57+
commentstyle=\color{codegreen},
58+
keywordstyle=\color{blue},
59+
% numberstyle=\tiny\color{codegray},
60+
stringstyle=\color{codepurple},
61+
basicstyle=\ttfamily\footnotesize,
62+
breakatwhitespace=false,
63+
breaklines=true,
64+
captionpos=b,
65+
keepspaces=true,
66+
numbers=left,
67+
numbersep=5pt,
68+
showspaces=false,
69+
showstringspaces=false,
70+
showtabs=false,
71+
tabsize=2
72+
}
73+
74+
\lstset{style=mystyle}
75+
5376
\begin{document}
5477

5578
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

formal-spec/measurements.tex

Lines changed: 141 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
\section{Impact on performance}
33
\label{sec:impact-on-performance}
44

5+
\subsection{Transaction Throughput}
6+
57
An important measurement of a blockchain system's performance is the number of
68
transaction bytes per-second ($\mathit{TBPS}$) it can sustain. Unlike the more
79
commonly used metric, transactions per-second, this number is not dependent on
@@ -141,8 +143,8 @@ \section{Impact on performance}
141143
ylabel={Usage percentage},
142144
ymin=0.0,
143145
ymax=250.0,
144-
ymode=linear,
145-
ytick={5.0, 20.0, 50.0, 100.0, 150.0, 200.0, 250.0},
146+
ymode=log,
147+
ytick={0.001, 0.01, 0.1, 1, 10, 100, 1000},
146148
legend pos=north west,
147149
ymajorgrids=true,
148150
grid style=dashed,
@@ -155,25 +157,151 @@ \section{Impact on performance}
155157
\label{fig:usage-vs-participants}
156158
\end{figure}
157159

158-
We can see that the impact on the system's performance is negligible even when
159-
we consider $100,000$ participants.
160+
We can see that the impact on the system's performance is negligible
161+
even when we consider $100,000$ participants. Moreover, we see that
162+
the usage consumption percentage scales linearly in the number of
163+
participants, i.e., a 10 times increase in the number of participants
164+
will only increase 10 times the required usage percent. Also, if we
165+
double the throughput, then we can process a double amount of
166+
participants workload at the same time.
160167
%
161-
These results indicate that the update protocol will start degrading the system
162-
performance \emph{only} past the 1,000,000 participants. Although this will
163-
require that the worst case conditions being met: 10 SIP's being voted at the
164-
same time over the period of 7 days, where each participant votes twice.
168+
These results indicate that the update protocol will start degrading
169+
the system performance \emph{only} past the 1,000,000 participants.
170+
Although this will require that the worst case conditions being met:
171+
10 SIP's being voted at the same time over the period of 7 days,
172+
where each participant votes twice.
165173
%
166-
In such case, relying on \emph{voting pools} (or \emph{expert pools}) becomes of
167-
crucial importance. In this way delegation of voting rights can help the update
168-
system is to scale beyond this number of participants. Alternatively, by
169-
increasing the duration of the vote period the impact on the system's
170-
performance can be mitigated.
174+
In such case, relying on \emph{voting pools} (or \emph{expert pools})
175+
becomes of crucial importance. In this way delegation of voting rights
176+
can help the update system is to scale beyond this number of
177+
participants. Alternatively, by increasing the duration of the vote
178+
period the impact on the system's performance can be mitigated.
171179

172180
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
173181
%% TODO: we need the revisit the section below considering the insight of
174182
%% the section above.
175183
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
176184

185+
\subsection{Processing Time and Memory Consumption}
186+
Clearly the most processing intesive task of the update mechanism
187+
is the tally phase. It is the phase where all the collected votes
188+
are counted in order to reach at a decision for a specific proposal.
189+
190+
We start with a theoretical time complexity analysis where we
191+
assume a worst-case scenario, where we have $n$ participants that all
192+
of them vote by submiting a single vote. Also we assume that we have
193+
a single proposal, so that within a voting period, the number $n$ of participants coincides to the number of submitted ballots.
194+
195+
In the following we try to break up the operations during the tally phase.
196+
In the heart of the tally phase lies the following function call,
197+
which is called for each proposal.
198+
199+
\begin{lstlisting}[language=Haskell, caption=Tally phase initial function call]
200+
tallyStake confidence result ballot stakeDistribution adversarialStakeRatio =
201+
if stakeThreshold adversarialStakeRatio (totalStake stakeDistribution)
202+
<
203+
stakeOfKeys votingKeys stakeDistribution
204+
then Just result
205+
else Nothing
206+
where
207+
votingKeys = Map.filter (== confidence) ballot
208+
\end{lstlisting}
209+
210+
\lstinline{Map.filter} \footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#g:25}}, is $O(n)$ so \lstinline{votingKeys} is $O(n)$, where $n$ is the number of ballots,
211+
which as we have said coincides to the number of participants. At
212+
this point, we have a single pass (loop) over $n$ ballots.
213+
214+
Furthermore, \lstinline{stakeOfKeys} makes the following calls:
215+
\begin{lstlisting}[language=Haskell, caption=Code example]
216+
stakeOfKeys
217+
keyMap
218+
StakeDistribution
219+
{ stakeMap
220+
}
221+
= Map.foldl (+) 0 $ stakeMap `Map.intersection` keyMap
222+
\end{lstlisting}
223+
224+
The $intersection$ function in the worst-case is $O(n)$\footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#v:intersection}}. Therefore this is a second pass
225+
(loop) over the data of length $n$.
226+
\lstinline{foldl} is also $O(n)$\footnote{\href{url}{http://hackage.haskell.org/package/containers-0.6.2.1/docs/Data-Map-Strict.html\#v:foldl}}. This is a third pass (loop) over the data of
227+
length $n$. Thus from the above analysis we see that we have for
228+
a single proposal a call of \lstinline{tallyStake}, where in each
229+
such call we have three passes over the data of length $n$. So in total
230+
for a single proposal we do $3$ passes over the data of length $n$.
231+
That is $3n$ operations, which means that the tally time
232+
complexity is $O(n)$.
233+
234+
This result is also confirmed by the experimental evaluation
235+
shown in the graph below:
236+
237+
\begin{figure}[htp]
238+
\centering
239+
240+
\begin{tikzpicture}
241+
\begin{axis}[
242+
title={Elapsed time (sec) vs Number of participants},
243+
xlabel={Participants},
244+
xmin=100.0,
245+
xmax=1.0e7,
246+
xmode=log,
247+
xtick={10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 1.0e7},
248+
ylabel={Elapsed time (sec)},
249+
ymin=0.0000001,
250+
ymax=10,
251+
ymode=log,
252+
ytick={0.0000001, 0.000001, 0.00001, 0.0001, 0.001, 0.01, 0.1, 1, 10},
253+
legend pos=north west,
254+
ymajorgrids=true,
255+
grid style=dashed,
256+
]
257+
\addplot[color=black] table {participants-vs-elapsed_time.dat};
258+
\end{axis}
259+
\end{tikzpicture}
260+
261+
\caption{Worst case scenario analysis for tally phase processing time}
262+
\label{fig:eltime-vs-participants}
263+
\end{figure}
264+
265+
In Figure \ref{fig:eltime-vs-participants}, we see that the elapsed
266+
time increases linearly in the number of participants. In addition,
267+
we see that it takes almost one tenth of a second to process
268+
the votes of $1$ million participants. These results correspond to
269+
a no-parallel execution of the tally algorithm on a i7 CPU laptop
270+
with 32GB of RAM.
271+
272+
Finally, we present the measurments of the memory consumption
273+
during the tally phase. Again as the graph in
274+
Figure \ref{fig:memcons-vs-participants} shows, the memory
275+
allocated scales linearly in the number of participants.
276+
277+
\begin{figure}[htp]
278+
\centering
279+
280+
\begin{tikzpicture}
281+
\begin{axis}[
282+
title={Memory consumed (bytes) vs Number of participants},
283+
xlabel={Participants},
284+
xmin=100.0,
285+
xmax=1.0e7,
286+
xmode=log,
287+
xtick={10.0, 100.0, 1000.0, 10000.0, 100000.0, 1000000.0, 1.0e7},
288+
ylabel={Memory consumed (bytes)},
289+
ymin=1.0e6,
290+
ymax=1.0e12,
291+
ymode=log,
292+
ytick={1.0e6, 1.0e7, 1.0e8, 1.0e9, 1.0e10, 1.0e11, 1.0e12},
293+
legend pos=north west,
294+
ymajorgrids=true,
295+
grid style=dashed,
296+
]
297+
\addplot[color=black] table {participants-vs-memory_consumed.dat};
298+
\end{axis}
299+
\end{tikzpicture}
300+
301+
\caption{Worst case scenario analysis for tally phase consumed memory}
302+
\label{fig:memcons-vs-participants}
303+
\end{figure}
304+
177305
\section{Measurements specification} \label{sec:measurements}
178306

179307
In this section we want to describe an experimental evaluation of our proposed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1.00E+02 4.01E-06
2+
1.00E+03 4.23E-05
3+
1.00E+04 4.53E-04
4+
1.00E+05 6.70E-03
5+
1.00E+06 7.50E-02
6+
1.00E+07 2.92E+00
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1.00E+02 3.22E+06
2+
1.00E+03 3.15E+07
3+
1.00E+04 3.18E+08
4+
1.00E+05 3.22E+09
5+
1.00E+06 3.25E+10
6+
1.00E+07 3.27E+11

0 commit comments

Comments
 (0)