source: doc/theses/thierry_delisle_PhD/thesis/text/eval_micro.tex @ a44514e

ADTast-experimentalpthread-emulation
Last change on this file since a44514e was a44514e, checked in by Thierry Delisle <tdelisle@…>, 19 months ago

A whole bunch of small changes:
trying to setup a version that I can pass through a spell checker.
Fixing a whole bunch of grammar errors

  • Property mode set to 100644
File size: 47.0 KB
Line 
1\chapter{Micro-Benchmarks}\label{microbench}
2
3The first step in evaluating this work is to test small controlled cases to ensure the basics work properly.
4This chapter presents five different experimental setups for evaluating the basic features of the \CFA, libfibre~\cite{libfibre}, Go, and Tokio~\cite{Tokio} schedulers.
5All of these systems have a \gls{uthrding} model.
6The goal in this chapter is show the \CFA scheduler obtains equivalent performance to other less fair schedulers through the different experiments.
7Note, only the code of the \CFA tests is shown;
8all tests in the other systems are functionally identical and available online~\cite{GITHUB:SchedulingBenchmarks}.
9
10\section{Benchmark Environment}\label{microenv}
11
12All benchmarks are run on two distinct hardware platforms.
13\begin{description}
14\item[AMD] is a server with two AMD EPYC 7662 CPUs and 256GB of DDR4 RAM.
15The EPYC CPU has 64 cores with 2 \glspl{hthrd} per core, for 128 \glspl{hthrd} per socket with 2 sockets for a total of 256 \glspl{hthrd}.
16Each CPU has 4 MB, 64 MB and 512 MB of L1, L2 and L3 caches, respectively.
17Each L1 and L2 instance are only shared by \glspl{hthrd} on a given core, but each L3 instance is shared by 4 cores, therefore 8 \glspl{hthrd}.
18The server runs Ubuntu 20.04.2 LTS on top of Linux Kernel 5.8.0-55.
19
20\item[Intel] is a server with four Intel Xeon Platinum 8160 CPUs and 384GB of DDR4 RAM.
21The Xeon CPU has 24 cores with 2 \glspl{hthrd} per core, for 48 \glspl{hthrd} per socket with 4 sockets for a total of 196 \glspl{hthrd}.
22Each CPU has 3 MB, 96 MB and 132 MB of L1, L2 and L3 caches respectively.
23Each L1 and L2 instance are only shared by \glspl{hthrd} on a given core, but each L3 instance is shared across the entire CPU, therefore 48 \glspl{hthrd}.
24The server runs Ubuntu 20.04.2 LTS on top of Linux Kernel 5.8.0-55.
25\end{description}
26
27For all benchmarks, @taskset@ is used to limit the experiment to 1 NUMA node with no hyper threading.
28If more \glspl{hthrd} are needed, then 1 NUMA node with hyperthreading is used.
29If still more \glspl{hthrd} are needed, then the experiment is limited to as few NUMA nodes as needed.
30For the Intel machine, this means that from 1 to 24 \procs one socket and \emph{no} hyperthreading is used, and from 25 to 48 \procs still only one socket is used but \emph{with} hyperthreading.
31This pattern is repeated between 49 and 96, between 97 and 144, and between 145 and 192.
32On AMD, the same algorithm is used, but the machine only has 2 sockets.
33So hyperthreading\footnote{
34Hyperthreading normally refers specifically to the technique used by Intel, however it is often used generically to refer to any equivalent feature.}
35is used when the \proc count reach 65 and 193.
36
37The limited sharing of the last-level cache on the AMD machine is markedly different than the Intel machine.
38Indeed, while on both architectures L2 cache misses that are served by L3 caches on a different CPU incur a significant latency, on the AMD it is also the case that cache misses served by a different L3 instance on the same CPU also incur high latency.
39
40\section{Experimental setup}
41
42Each experiment is run 15 times varying the number of processors depending on the two different computers.
43All experiments gather throughput data and secondary data for scalability or latency.
44The data is graphed using a solid, a dashed, and a dotted line, representing the median, maximum and minimum result respectively, where the minimum/maximum lines are referred to as the \emph{extremes}.\footnote{
45An alternative display is to use error bars with min/max as the bottom/top for the bar.
46However, this approach is not truly an error bar around a mean value and I felt the connected lines are easier to read.}
47This graph presentation offers an overview of the distribution of the results for each experiment.
48
49For each experiment, four graphs are generated showing traditional throughput on the top row and \newterm{scalability} or \newterm{latency} on the bottom row (peek ahead to Figure~\ref{fig:cycle:jax}).
50Scalability uses the same data as throughput but the Y axis is calculated as the number of \procs over the throughput.
51In this representation, perfect scalability should appear as a horizontal line, \eg, if doubling the number of \procs doubles the throughput, then the relation stays the same.
52
53The left column shows results for hundreds of \ats per \proc, enough to always keep every \proc busy.
54The right column shows results for very few \ats per \proc, where the ready queues are expected to be near empty most of the time.
55The distinction between many and few \ats is meaningful because the idle sleep subsystem is expected to matter only in the right column, where spurious effects can cause a \proc to run out of work temporarily.
56
57\section{Cycle}
58
59The most basic evaluation of any ready queue is the latency needed to push and pop one element from the ready queue.
60Since these two operations also describe a @yield@ operation, many systems use this operation as the fundamental benchmark.
61However, yielding can be treated as a special case by optimizing it away since the number of ready \ats does not change.
62Hence, systems that perform this optimization have an artificial performance benefit because the yield becomes a \emph{nop}.
63For this reason, I designed a different push/pop benchmark, called \newterm{Cycle Benchmark}.
64This benchmark arranges a number of \ats into a ring, as seen in Figure~\ref{fig:cycle}, where the ring is a circular singly-linked list.
65At runtime, each \at unparks the next \at before \glslink{atblock}{parking} itself.
66Unparking the next \at pushes that \at onto the ready queue while the ensuing \park leads to a \at being popped from the ready queue.
67
68\begin{figure}
69        \centering
70        \input{cycle.pstex_t}
71        \caption[Cycle benchmark]{Cycle benchmark\smallskip\newline Each \at unparks the next \at in the cycle before \glslink{atblock}{parking} itself.}
72        \label{fig:cycle}
73\end{figure}
74
75Therefore, the underlying runtime cannot rely on the number of ready \ats staying constant over the duration of the experiment.
76In fact, the total number of \ats waiting on the ready queue is expected to vary because of the race between the next \at \glslink{atsched}{unparking} and the current \at \glslink{atblock}{parking}.
77That is, the runtime cannot anticipate that the current task immediately parks.
78As well, the size of the cycle is also decided based on this race, \eg a small cycle may see the chain of unparks go full circle before the first \at parks because of time-slicing or multiple \procs.
79If this happens, the scheduler push and pop are avoided and the results of the experiment are skewed.
80(Note, an \unpark is like a V on a semaphore, so the subsequent \park (P) may not block.)
81Every runtime system must handle this race and cannot optimized away the ready-queue pushes and pops.
82To prevent any attempt of silently omitting ready-queue operations, the ring of \ats is made big enough so the \ats have time to fully \park before being unparked again.
83Finally, to further mitigate any underlying push/pop optimizations, especially on SMP machines, multiple rings are created in the experiment.
84
85Figure~\ref{fig:cycle:code} shows the pseudo code for this benchmark, where each cycle has 5 \ats.
86There is additional complexity to handle termination (not shown), which requires a binary semaphore or a channel instead of raw \park/\unpark and carefully picking the order of the @P@ and @V@ with respect to the loop condition.
87
88\begin{figure}
89\begin{cfa}
90Thread.main() {
91        count := 0
92        for {
93                @this.next.wake()@
94                @wait()@
95                count ++
96                if must_stop() { break }
97        }
98        global.count += count
99}
100\end{cfa}
101\caption[Cycle Benchmark : Pseudo Code]{Cycle Benchmark : Pseudo Code}
102\label{fig:cycle:code}
103\bigskip
104        \subfloat[][Throughput, 100 cycles per \proc]{
105                \resizebox{0.5\linewidth}{!}{
106                        \input{result.cycle.jax.ops.pstex_t}
107                }
108                \label{fig:cycle:jax:ops}
109        }
110        \subfloat[][Throughput, 1 cycle per \proc]{
111                \resizebox{0.5\linewidth}{!}{
112                        \input{result.cycle.low.jax.ops.pstex_t}
113                }
114                \label{fig:cycle:jax:low:ops}
115        }
116
117        \subfloat[][Scalability, 100 cycles per \proc]{
118                \resizebox{0.5\linewidth}{!}{
119                        \input{result.cycle.jax.ns.pstex_t}
120                }
121                \label{fig:cycle:jax:ns}
122        }
123        \subfloat[][Scalability, 1 cycle per \proc]{
124                \resizebox{0.5\linewidth}{!}{
125                        \input{result.cycle.low.jax.ns.pstex_t}
126                }
127                \label{fig:cycle:jax:low:ns}
128        }
129        \caption[Cycle Benchmark on Intel]{Cycle Benchmark on Intel\smallskip\newline Throughput and scalability as a function of \proc count, 5 \ats per cycle, and different cycle counts.
130        For throughput, higher is better, for scalability, lower is better.
131        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
132        \label{fig:cycle:jax}
133\end{figure}
134
135\begin{figure}
136        \subfloat[][Throughput, 100 cycles per \proc]{
137                \resizebox{0.5\linewidth}{!}{
138                        \input{result.cycle.nasus.ops.pstex_t}
139                }
140                \label{fig:cycle:nasus:ops}
141        }
142        \subfloat[][Throughput, 1 cycle per \proc]{
143                \resizebox{0.5\linewidth}{!}{
144                        \input{result.cycle.low.nasus.ops.pstex_t}
145                }
146                \label{fig:cycle:nasus:low:ops}
147        }
148
149        \subfloat[][Scalability, 100 cycles per \proc]{
150                \resizebox{0.5\linewidth}{!}{
151                        \input{result.cycle.nasus.ns.pstex_t}
152                }
153                \label{fig:cycle:nasus:ns}
154        }
155        \subfloat[][Scalability, 1 cycle per \proc]{
156                \resizebox{0.5\linewidth}{!}{
157                        \input{result.cycle.low.nasus.ns.pstex_t}
158                }
159                \label{fig:cycle:nasus:low:ns}
160        }
161        \caption[Cycle Benchmark on AMD]{Cycle Benchmark on AMD\smallskip\newline Throughput and scalability as a function of \proc count, 5 \ats per cycle, and different cycle counts.
162        For throughput, higher is better, for scalability, lower is better.
163        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
164        \label{fig:cycle:nasus}
165\end{figure}
166
167\subsection{Results}
168
169Figures~\ref{fig:cycle:jax} and \ref{fig:cycle:nasus} show the results for the cycle experiment on Intel and AMD, respectively.
170Looking at the left column on Intel, Figures~\ref{fig:cycle:jax:ops} and \ref{fig:cycle:jax:ns} show the results for 100 cycles of 5 \ats for each \proc.
171\CFA, Go and Tokio all obtain effectively the same throughput performance.
172Libfibre is slightly behind in this case but still scales decently.
173As a result of the \gls{kthrd} placement, additional \procs from 25 to 48 offer less performance improvement for all runtimes, which can be seen as a flatting of the line.
174This effect even causes a decrease in throughput in libfibre's case.
175As expected, this pattern repeats again between \proc count 72 and 96.
176
177Looking next at the right column on Intel, Figures~\ref{fig:cycle:jax:low:ops} and \ref{fig:cycle:jax:low:ns} show the results for 1 cycle of 5 \ats for each \proc.
178\CFA and Tokio obtain very similar results overall, but Tokio shows more variations in the results.
179Go achieves slightly better performance than \CFA and Tokio, but all three display significantly worst performance compared to the left column.
180This decrease in performance is likely due to the additional overhead of the idle-sleep mechanism.
181This can either be the result of \procs actually running out of work, or simply additional overhead from tracking whether or not there is work available.
182Indeed, unlike the left column, it is likely that the ready-queue is transiently empty, which likely triggers additional synchronization steps.
183Interestingly, libfibre achieves better performance with 1 cycle.
184
185Looking now at the results for the AMD architecture, Figure~\ref{fig:cycle:nasus}, the results are overall similar to the Intel results, but with close to double the performance, slightly increased variation, and some differences in the details.
186Note the maximum of the Y-axis on Intel and AMD differ significantly.
187Looking at the left column on AMD, Figures~\ref{fig:cycle:nasus:ops} and \ref{fig:cycle:nasus:ns} all 4 runtimes achieve very similar throughput and scalability.
188However, as the number of \procs grows higher, the results on AMD show notably more variability than on Intel.
189The different performance improvements and plateaus are due to cache topology and appear at the expected: \proc counts of 64, 128 and 192, for the same reasons as on Intel.
190Looking next at the right column on AMD, Figures~\ref{fig:cycle:nasus:low:ops} and \ref{fig:cycle:nasus:low:ns}, Tokio and Go have the same throughput performance, while \CFA is slightly slower.
191This result is different than on Intel, where Tokio behaved like \CFA rather than behaving like Go.
192Again, the same performance increase for libfibre is visible when running fewer \ats.
193Note, I did not investigate the libfibre performance boost for 1 cycle in this experiment.
194
195The conclusion from both architectures is that all of the compared runtime have fairly equivalent performance for this micro-benchmark.
196Clearly, the pathological case with 1 cycle per \proc can affect fairness algorithms managing mostly idle processors, \eg \CFA, but only at high core counts.
197For this case, \emph{any} helping is likely to cause a cascade of \procs running out of work and attempting to steal.
198For this experiment, the \CFA scheduler has achieved the goal of obtaining equivalent performance to other less fair schedulers.
199
200\section{Yield}
201
202For completeness, the classic yield benchmark is included.
203Here, the throughput is dominated by the mechanism used to handle the @yield@ function.
204Figure~\ref{fig:yield:code} shows pseudo code for this benchmark, where the cycle @wait/next.wake@ is replaced by @yield@.
205As mentioned, this benchmark may not be representative because of optimization shortcuts in @yield@.
206The only interesting variable in this benchmark is the number of \ats per \procs, where ratios close to 1 means the ready queue(s) can be empty, which again puts a strain on the idle-sleep handling.
207
208\begin{figure}
209\begin{cfa}
210Thread.main() {
211        count := 0
212        for {
213                @yield()@
214                count ++
215                if must_stop() { break }
216        }
217        global.count += count
218}
219\end{cfa}
220\caption[Yield Benchmark : Pseudo Code]{Yield Benchmark : Pseudo Code}
221\label{fig:yield:code}
222%\end{figure}
223\bigskip
224%\begin{figure}
225        \subfloat[][Throughput, 100 \ats per \proc]{
226                \resizebox{0.5\linewidth}{!}{
227                        \input{result.yield.jax.ops.pstex_t}
228                }
229                \label{fig:yield:jax:ops}
230        }
231        \subfloat[][Throughput, 1 \ats per \proc]{
232                \resizebox{0.5\linewidth}{!}{
233                \input{result.yield.low.jax.ops.pstex_t}
234                }
235                \label{fig:yield:jax:low:ops}
236        }
237
238        \subfloat[][Scalability, 100 \ats per \proc]{
239                \resizebox{0.5\linewidth}{!}{
240                \input{result.yield.jax.ns.pstex_t}
241                }
242                \label{fig:yield:jax:ns}
243        }
244        \subfloat[][Scalability, 1 \ats per \proc]{
245                \resizebox{0.5\linewidth}{!}{
246                \input{result.yield.low.jax.ns.pstex_t}
247                }
248                \label{fig:yield:jax:low:ns}
249        }
250        \caption[Yield Benchmark on Intel]{Yield Benchmark on Intel\smallskip\newline Throughput and scalability as a function of \proc count.
251        For throughput, higher is better, for scalability, lower is better.
252        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
253        \label{fig:yield:jax}
254\end{figure}
255
256\subsection{Results}
257
258Figures~\ref{fig:yield:jax} and \ref{fig:yield:nasus} show the results for the yield experiment on Intel and AMD, respectively.
259Looking at the left column on Intel, Figures~\ref{fig:yield:jax:ops} and \ref{fig:yield:jax:ns} show the results for 100 \ats for each \proc.
260Note, the Y-axis on this graph is twice as large as the Intel cycle-graph.
261A visual glance between the left columns of the cycle and yield graphs confirms my claim that the yield benchmark is unreliable.
262\CFA has no special handling for @yield@, but this experiment requires less synchronization than the @cycle@ experiment.
263Hence, the @yield@ throughput and scalability graphs have similar shapes to the corresponding @cycle@ graphs.
264The only difference is sightly better performance for @yield@ because of less synchronization.
265Libfibre has special handling for @yield@ using the fact that the number of ready fibres does not change, and therefore, by-passing the idle-sleep mechanism entirely.
266Hence, libfibre behaves very differently in the cycle and yield benchmarks, with a 4 times increase in performance on the left column.
267Go has special handling for @yield@ by putting a yielding goroutine on a secondary global ready-queue, giving it lower priority.
268The result is that multiple \glspl{hthrd} contend for the global queue and performance suffers drastically.
269Hence, Go behaves very differently in the cycle and yield benchmarks, with a complete performance collapse in @yield@.
270Tokio has a similar performance collapse after 16 processors, and therefore, its special @yield@ handling is probably related to a Go-like scheduler problem and/or a \CFA idle-sleep problem.
271(I did not dig through the Rust code to ascertain the exact reason for the collapse.)
272Note that since there is no communication among \ats, locality problems are much less likely than for the cycle benchmark.
273This lack of communication is probably why the plateaus due to topology are not present.
274
275Looking next at the right column on Intel, Figures~\ref{fig:yield:jax:low:ops} and \ref{fig:yield:jax:low:ns} show the results for 1 \at for each \proc.
276As for @cycle@, \CFA's cost of idle sleep comes into play in a very significant way in Figure~\ref{fig:yield:jax:low:ns}, where the scaling is not flat.
277This result is to be expected since fewer \ats means \procs are more likely to run out of work.
278On the other hand, when only running 1 \at per \proc, libfibre optimizes further, and forgoes the context-switch entirely.
279This results in libfibre outperforming other runtimes even more, achieving 8 times more throughput than for @cycle@.
280Finally, Go and Tokio performance collapse is still the same with fewer \ats.
281The only exception is Tokio running on 24 \proc, deepening the mystery of its yielding mechanism further.
282
283\begin{figure}
284        \subfloat[][Throughput, 100 \ats per \proc]{
285                \resizebox{0.5\linewidth}{!}{
286                        \input{result.yield.nasus.ops.pstex_t}
287                }
288                \label{fig:yield:nasus:ops}
289        }
290        \subfloat[][Throughput, 1 \at per \proc]{
291                \resizebox{0.5\linewidth}{!}{
292                        \input{result.yield.low.nasus.ops.pstex_t}
293                }
294                \label{fig:yield:nasus:low:ops}
295        }
296
297        \subfloat[][Scalability, 100 \ats per \proc]{
298                \resizebox{0.5\linewidth}{!}{
299                        \input{result.yield.nasus.ns.pstex_t}
300                }
301                \label{fig:yield:nasus:ns}
302        }
303        \subfloat[][Scalability, 1 \at per \proc]{
304                \resizebox{0.5\linewidth}{!}{
305                        \input{result.yield.low.nasus.ns.pstex_t}
306                }
307                \label{fig:yield:nasus:low:ns}
308        }
309        \caption[Yield Benchmark on AMD]{Yield Benchmark on AMD\smallskip\newline Throughput and scalability as a function of \proc count.
310        For throughput, higher is better, for scalability, lower is better.
311        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
312        \label{fig:yield:nasus}
313\end{figure}
314
315Looking now at the results for the AMD architecture, Figure~\ref{fig:yield:nasus}, the results again show a story that is overall similar to the results on the Intel, with increased variation and some differences in the details.
316Note that the maximum of the Y-axis on Intel and AMD differ less in @yield@ than @cycle@.
317Looking at the left column first, Figures~\ref{fig:yield:nasus:ops} and \ref{fig:yield:nasus:ns}, \CFA achieves very similar throughput and scaling.
318Libfibre still outpaces all other runtimes, but it encounter a performance hit at 64 \procs.
319This anomaly suggest some amount of communication between the \procs that the Intel machine is able to mask where the AMD is not once hyperthreading is needed.
320Go and Tokio still display the same performance collapse as on Intel.
321Looking next at the right column on AMD, Figures~\ref{fig:yield:nasus:low:ops} and \ref{fig:yield:nasus:low:ns}, all runtime systems effectively behave the same as they did on the Intel machine.
322At the high \ats count, the only difference is Libfibre's scaling and this difference disappears on the right column.
323This behaviour suggest whatever communication issue it encountered on the left is completely circumvented on the right.
324
325It is difficult to draw conclusions for this benchmark when runtime system treat @yield@ so differently.
326The win for \CFA is its consistency between the cycle and yield benchmarks making it simpler for programmers to use and understand, \ie the \CFA semantics match with programmer intuition.
327
328
329\section{Churn}
330
331The Cycle and Yield benchmark represent an \emph{easy} scenario for a scheduler, \eg an embarrassingly parallel application.
332In these benchmarks, \ats can be easily partitioned over the different \procs upfront and none of the \ats communicate with each other.
333
334The Churn benchmark represents more chaotic executions, where there is more communication among \ats but no relationship between the last \proc on which a \at ran and blocked, and the \proc that subsequently unblocks it.
335With processor-specific ready-queues, when a \at is unblocked by a different \proc that means the unblocking \proc must either ``steal'' the \at from another processor or find it on a remote queue.
336This dequeuing results in either contention on the remote queue and/or \glspl{rmr} on the \at data structure.
337Hence, this benchmark has performance dominated by the cache traffic as \procs are constantly accessing each other's data.
338In either case, this benchmark aims to measure how well a scheduler handles these cases, since both cases can lead to performance degradation if not handled correctly.
339
340This benchmark uses a fixed-size array of counting semaphores.
341Each \at picks a random semaphore, @V@s it to unblock any waiting \at, and then @P@s (maybe blocks) the \at on the semaphore.
342This creates a flow where \ats push each other out of the semaphores before being pushed out themselves.
343For this benchmark to work, the number of \ats must be equal or greater than the number of semaphores plus the number of \procs;
344\eg if there are 10 semaphores and 5 \procs, but only 3 \ats, all 3 \ats can block (P) on a random semaphore and now there is no \ats to unblock (V) them.
345Note, the nature of these semaphores mean the counter can go beyond 1, which can lead to nonblocking calls to @P@.
346Figure~\ref{fig:churn:code} shows pseudo code for this benchmark, where the @yield@ is replaced by @V@ and @P@.
347
348\begin{figure}
349\begin{cfa}
350Thread.main() {
351        count := 0
352        for {
353                r := random() % len(spots)
354                @spots[r].V()@
355                @spots[r].P()@
356                count ++
357                if must_stop() { break }
358        }
359        global.count += count
360}
361\end{cfa}
362\caption[Churn Benchmark : Pseudo Code]{Churn Benchmark : Pseudo Code}
363\label{fig:churn:code}
364%\end{figure}
365\bigskip
366%\begin{figure}
367        \subfloat[][Throughput, 100 \ats per \proc]{
368                \resizebox{0.5\linewidth}{!}{
369                        \input{result.churn.jax.ops.pstex_t}
370                }
371                \label{fig:churn:jax:ops}
372        }
373        \subfloat[][Throughput, 2 \ats per \proc]{
374                \resizebox{0.5\linewidth}{!}{
375                        \input{result.churn.low.jax.ops.pstex_t}
376                }
377                \label{fig:churn:jax:low:ops}
378        }
379
380        \subfloat[][Scalability, 100 \ats per \proc]{
381                \resizebox{0.5\linewidth}{!}{
382                        \input{result.churn.jax.ns.pstex_t}
383                }
384                \label{fig:churn:jax:ns}
385        }
386        \subfloat[][Scalability, 2 \ats per \proc]{
387                \resizebox{0.5\linewidth}{!}{
388                        \input{result.churn.low.jax.ns.pstex_t}
389                }
390                \label{fig:churn:jax:low:ns}
391        }
392        \caption[Churn Benchmark on Intel]{Churn Benchmark on Intel\smallskip\newline Throughput and scalability of the Churn on the benchmark on the Intel machine.
393        For throughput, higher is better, for scalability, lower is better.
394        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
395        \label{fig:churn:jax}
396\end{figure}
397
398\subsection{Results}
399
400Figures~\ref{fig:churn:jax} and Figure~\ref{fig:churn:nasus} show the results for the churn experiment on Intel and AMD, respectively.
401Looking at the left column on Intel, Figures~\ref{fig:churn:jax:ops} and \ref{fig:churn:jax:ns} show the results for 100 \ats for each \proc, and all runtimes obtain fairly similar throughput for most \proc counts.
402\CFA does very well on a single \proc but quickly loses its advantage over the other runtimes.
403As expected, it scales decently up to 48 \procs, drops from 48 to 72 \procs, and then plateaus.
404Tokio achieves very similar performance to \CFA, with the starting boost, scaling decently until 48 \procs, drops from 48 to 72 \procs, and starts increasing again to 192 \procs.
405Libfibre obtains effectively the same results as Tokio with slightly less scaling, \ie the scaling curve is the same but with slightly lower values.
406Finally, Go gets the most peculiar results, scaling worst than other runtimes until 48 \procs.
407At 72 \procs, the results of the Go runtime vary significantly, sometimes scaling sometimes plateauing.
408However, beyond this point Go keeps this level of variation but does not scale further in any of the runs.
409
410Throughput and scalability is notably worst for all runtimes than the previous benchmarks since there is inherently more communication between processors.
411Indeed, none of the runtimes reach 40 million operations per second while in the cycle benchmark all but libfibre reached 400 million operations per second.
412Figures~\ref{fig:churn:jax:ns} and \ref{fig:churn:jax:low:ns} show that for all \proc count, all runtimes produce poor scaling.
413However, once the number of \glspl{hthrd} goes beyond a single socket, at 48 \procs, scaling goes from bad to worst and performance completely ceases to improve.
414At this point, the benchmark is dominated by inter-socket communication costs for all runtimes.
415
416An interesting aspect to note here is that the runtimes differ in how they handle this situation.
417Indeed, when a \proc unparks a \at that was last run on a different \proc, the \at could be appended to the ready queue of the local \proc or to the ready queue of the remote \proc, which previously ran the \at.
418\CFA, Tokio and Go all use the approach of \glslink{atsched}{unparking} to the local \proc, while Libfibre unparks to the remote \proc.
419In this particular benchmark, the inherent chaos of the benchmark, in addition to small memory footprint, means neither approach wins over the other.
420
421Looking next at the right column on Intel, Figures~\ref{fig:churn:jax:low:ops} and \ref{fig:churn:jax:low:ns} show the results for 1 \at for each \proc, and many of the differences between the runtimes disappear.
422\CFA outperforms other runtimes by a minuscule margin.
423Libfibre follows very closely behind with basically the same performance and scaling.
424Tokio maintains effectively the same curve shapes as \CFA and libfibre, but it incurs extra costs for all \proc counts.
425While Go maintains overall similar results to the others, it again encounters significant variation at high \proc counts.
426Inexplicably resulting in super-linear scaling for some runs, \ie the scalability curves displays a negative slope.
427
428Interestingly, unlike the cycle benchmark, running with fewer \ats does not produce drastically different results.
429In fact, the overall throughput stays almost exactly the same on the left and right column.
430
431\begin{figure}
432        \subfloat[][Throughput, 100 \ats per \proc]{
433                \resizebox{0.5\linewidth}{!}{
434                        \input{result.churn.nasus.ops.pstex_t}
435                }
436                \label{fig:churn:nasus:ops}
437        }
438        \subfloat[][Throughput, 2 \ats per \proc]{
439                \resizebox{0.5\linewidth}{!}{
440                        \input{result.churn.low.nasus.ops.pstex_t}
441                }
442                \label{fig:churn:nasus:low:ops}
443        }
444
445        \subfloat[][Scalability, 100 \ats per \proc]{
446                \resizebox{0.5\linewidth}{!}{
447                        \input{result.churn.nasus.ns.pstex_t}
448                }
449                \label{fig:churn:nasus:ns}
450        }
451        \subfloat[][Scalability, 2 \ats per \proc]{
452                \resizebox{0.5\linewidth}{!}{
453                        \input{result.churn.low.nasus.ns.pstex_t}
454                }
455                \label{fig:churn:nasus:low:ns}
456        }
457        \caption[Churn Benchmark on AMD]{Churn Benchmark on AMD\smallskip\newline Throughput and scalability of the Churn on the benchmark on the AMD machine.
458        For throughput, higher is better, for scalability, lower is better.
459        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
460        \label{fig:churn:nasus}
461\end{figure}
462
463
464Looking now at the results for the AMD architecture, Figure~\ref{fig:churn:nasus}, the results show a somewhat different story.
465Looking at the left column first, Figures~\ref{fig:churn:nasus:ops} and \ref{fig:churn:nasus:ns}, \CFA, Libfibre and Tokio all produce decent scalability.
466\CFA suffers particular from a larger variations at higher \proc counts, but largely outperforms the other runtimes.
467Go still produces intriguing results in this case and even more intriguingly, the results have fairly low variation.
468
469One possible explanation for Go's difference is that it has very few available concurrent primitives, so a channel is substituted for a semaphore.
470On paper a semaphore can be replaced by a channel, and with zero-sized objects passed through the channel, equivalent performance could be expected.
471However, in practice, there are implementation difference between the two, \eg if the semaphore count can get somewhat high so object accumulate in the channel.
472Note that this substitution is also made in the cycle benchmark;
473however, in that context, it did not have a notable impact.
474
475As second possible explanation is that Go may use the heap when allocating variables based on the result of escape analysis of the code.
476It is possible for variables that could be placed on the stack to instead be placed on the heap.
477This placement could cause extra pointer chasing in the benchmark, heightening locality effects.
478Depending on how the heap is structure, this could also lead to false sharing.
479I did not investigate what causes these unusual results.
480
481Looking next at the right column, Figures~\ref{fig:churn:nasus:low:ops} and \ref{fig:churn:nasus:low:ns}, as for Intel, all runtimes obtain overall similar throughput between the left and right column.
482\CFA, Libfibre and Tokio all have very close results.
483Go still suffers from poor scalability but is now unusual in a different way.
484While it obtains effectively constant performance regardless of \proc count, this ``sequential'' performance is higher than the other runtimes for low \proc count.
485Up to 32 \procs, after which the other runtime manage to outscale Go.
486
487In conclusion, the objective of this benchmark is to demonstrate that \glslink{atsched}{unparking} \ats from remote \procs does not cause too much contention on the local queues.
488Indeed, the fact that most runtimes achieve some scaling between various \proc count demonstrate migrations do not need to be serialized.
489Again these result demonstrate \CFA achieves satisfactory performance with respect to the other runtimes.
490
491\section{Locality}
492
493As mentioned in the churn benchmark, when \glslink{atsched}{unparking} a \at, it is possible to either \unpark to the local or remote ready-queue.\footnote{
494It is also possible to \unpark to a third unrelated ready-queue, but without additional knowledge about the situation, it is likely to degrade performance.}
495The locality experiment includes two variations of the churn benchmark, where a data array is added.
496In both variations, before @V@ing the semaphore, each \at calls a @work@ function which increments random cells inside the data array.
497In the noshare variation, the array is not passed on and each thread continuously accesses its private array.
498In the share variation, the array is passed to another thread via the semaphore's shadow-queue (each blocking thread can save a word of user data in its blocking node), transferring ownership of the array to the woken thread.
499Figure~\ref{fig:locality:code} shows pseudo code for this benchmark.
500
501The objective here is to highlight the different decision made by the runtime when \glslink{atsched}{unparking}.
502Since each thread unparks a random semaphore, it means that it is unlikely that a \at is unparked from the last \proc it ran on.
503In the noshare variation, \glslink{atsched}{unparking} the \at on the local \proc is an appropriate choice since the data was last modified on that \proc.
504In the shared variation, \glslink{atsched}{unparking} the \at on a remote \proc is an appropriate choice.
505
506The expectation for this benchmark is to see a performance inversion, where runtimes fare notably better in the variation which matches their \glslink{atsched}{unparking} policy.
507This decision should lead to \CFA, Go and Tokio achieving better performance in the share variation while libfibre achieves better performance in noshare.
508Indeed, \CFA, Go and Tokio have the default policy of \glslink{atsched}{unparking} \ats on the local \proc, where as libfibre has the default policy of \glslink{atsched}{unparking} \ats wherever they last ran.
509
510\begin{figure}
511\newsavebox{\myboxA}
512\newsavebox{\myboxB}
513
514\begin{lrbox}{\myboxA}
515\begin{cfa}[tabsize=3]
516Thread.main() {
517        count := 0
518        for {
519                r := random() % len(spots)
520                // go through the array
521                @work( a )@
522
523                spots[r].V()
524                spots[r].P()
525                count ++
526                if must_stop() { break }
527        }
528        global.count += count
529}
530\end{cfa}
531\end{lrbox}
532
533\begin{lrbox}{\myboxB}
534\begin{cfa}[tabsize=3]
535Thread.main() {
536        count := 0
537        for {
538                r := random() % len(spots)
539                // go through the array
540                @work( a )@
541                // pass array to next thread
542                spots[r].V( @a@ )
543                @a = @spots[r].P()
544                count ++
545                if must_stop() { break }
546        }
547        global.count += count
548}
549\end{cfa}
550\end{lrbox}
551
552\subfloat[Noshare]{\label{fig:locality:code:T1}\usebox\myboxA}
553\hspace{3pt}
554\vrule
555\hspace{3pt}
556\subfloat[Share]{\label{fig:locality:code:T2}\usebox\myboxB}
557
558\caption[Locality Benchmark : Pseudo Code]{Locality Benchmark : Pseudo Code}
559\label{fig:locality:code}
560\end{figure}
561
562\subsection{Results}
563
564Figures~\ref{fig:locality:jax} and \ref{fig:locality:nasus} show the results for the locality experiment on Intel and AMD, respectively.
565In both cases, the graphs on the left column show the results for the share variation and the graphs on the right column show the results for the noshare.
566Looking at the left column on Intel, Figures~\ref{fig:locality:jax:share:ops} and \ref{fig:locality:jax:share:ns} show the results for the share variation.
567\CFA and Tokio slightly outperform libfibre, as expected, based on their \ats placement approach.
568\CFA and Tokio both \unpark locally and do not suffer cache misses on the transferred array.
569Libfibre on the other hand unparks remotely, and as such the unparked \at is likely to miss on the shared data.
570Go trails behind in this experiment, presumably for the same reasons that were observable in the churn benchmark.
571Otherwise, the results are similar to the churn benchmark, with lower throughput due to the array processing.
572As for most previous results, all runtimes suffer a performance hit after 48 \proc, which is the socket boundary, and climb again from 96 to 192 \procs.
573
574\begin{figure}
575        \subfloat[][Throughput share]{
576                \resizebox{0.5\linewidth}{!}{
577                        \input{result.locality.share.jax.ops.pstex_t}
578                }
579                \label{fig:locality:jax:share:ops}
580        }
581        \subfloat[][Throughput noshare]{
582                \resizebox{0.5\linewidth}{!}{
583                        \input{result.locality.noshare.jax.ops.pstex_t}
584                }
585                \label{fig:locality:jax:noshare:ops}
586        }
587
588        \subfloat[][Scalability share]{
589                \resizebox{0.5\linewidth}{!}{
590                        \input{result.locality.share.jax.ns.pstex_t}
591                }
592                \label{fig:locality:jax:share:ns}
593        }
594        \subfloat[][Scalability noshare]{
595                \resizebox{0.5\linewidth}{!}{
596                        \input{result.locality.noshare.jax.ns.pstex_t}
597                }
598                \label{fig:locality:jax:noshare:ns}
599        }
600        \caption[Locality Benchmark on Intel]{Locality Benchmark on Intel\smallskip\newline Throughput and scalability as a function of \proc count.
601        For throughput, higher is better, for scalability, lower is better.
602        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
603        \label{fig:locality:jax}
604\end{figure}
605
606\begin{figure}
607        \subfloat[][Throughput share]{
608                \resizebox{0.5\linewidth}{!}{
609                        \input{result.locality.share.nasus.ops.pstex_t}
610                }
611                \label{fig:locality:nasus:share:ops}
612        }
613        \subfloat[][Throughput noshare]{
614                \resizebox{0.5\linewidth}{!}{
615                        \input{result.locality.noshare.nasus.ops.pstex_t}
616                }
617                \label{fig:locality:nasus:noshare:ops}
618        }
619
620        \subfloat[][Scalability share]{
621                \resizebox{0.5\linewidth}{!}{
622                        \input{result.locality.share.nasus.ns.pstex_t}
623                }
624                \label{fig:locality:nasus:share:ns}
625        }
626        \subfloat[][Scalability noshare]{
627                \resizebox{0.5\linewidth}{!}{
628                        \input{result.locality.noshare.nasus.ns.pstex_t}
629                }
630                \label{fig:locality:nasus:noshare:ns}
631        }
632        \caption[Locality Benchmark on AMD]{Locality Benchmark on AMD\smallskip\newline Throughput and scalability as a function of \proc count.
633        For throughput, higher is better, for scalability, lower is better.
634        Each series represent 15 independent runs, the dashed lines are maximums of each series while the solid lines are the median and the dotted lines are the minimums.}
635        \label{fig:locality:nasus}
636\end{figure}
637
638Looking at the right column on Intel, Figures~\ref{fig:locality:jax:noshare:ops} and \ref{fig:locality:jax:noshare:ns} show the results for the noshare variation.
639The graphs show the expected performance inversion where libfibre now outperforms \CFA and Tokio.
640Indeed, in this case, unparking remotely means the unparked \at is less likely to suffer a cache miss on the array, which leaves the \at data structure and the remote queue as the only source of likely cache misses.
641Results show both are amortized fairly well in this case.
642\CFA and Tokio both \unpark locally and as a result suffer a marginal performance degradation from the cache miss on the array.
643
644Looking at the results for the AMD architecture, Figure~\ref{fig:locality:nasus}, shows results similar to the Intel.
645Again overall performance is higher and slightly more variation is visible.
646Looking at the left column first, Figures~\ref{fig:locality:nasus:share:ops} and \ref{fig:locality:nasus:share:ns}, \CFA and Tokio still outperform libfibre, this time more significantly.
647This advantage is expected from the AMD server with its smaller and more narrow caches that magnify the costs of processing the array.
648Go still has the same poor performance as on Intel.
649
650Finally looking at the right column, Figures~\ref{fig:locality:nasus:noshare:ops} and \ref{fig:locality:nasus:noshare:ns}, like on Intel, the same performance inversion is present between libfibre and \CFA/Tokio.
651Go still has the same poor performance.
652
653Overall, this benchmark mostly demonstrates the two options available when \glslink{atsched}{unparking} a \at.
654Depending on the workload, either of these options can be the appropriate one.
655Since it is prohibitively difficult to dynamically detect which approach is appropriate, all runtimes much choose one of the two and live with the consequences.
656
657Once again, these experiments demonstrate that \CFA achieves equivalent performance to the other runtimes, in this case matching the faster Tokio rather than Go, which is trailing behind.
658
659\section{Transfer}
660The last benchmark is more of an experiment than a benchmark.
661It tests the behaviour of the schedulers for a misbehaved workload.
662In this workload, one \at is selected at random to be the leader.
663The leader then spins in a tight loop until it has observed that all other \ats have acknowledged its leadership.
664The leader \at then picks a new \at to be the next leader and the cycle repeats.
665The benchmark comes in two variations for the non-leader \ats:
666once they acknowledged the leader, they either block on a semaphore or spin yielding.
667Figure~\ref{fig:transfer:code} shows pseudo code for this benchmark.
668
669\begin{figure}
670\begin{cfa}
671Thread.lead() {
672        this.idx_seen = ++lead_idx
673        if lead_idx > stop_idx {
674                done := true
675                return
676        }
677        // Wait for everyone to acknowledge my leadership
678        start: = timeNow()
679        for t in threads {
680                while t.idx_seen != lead_idx {
681                        asm pause
682                        if (timeNow() - start) > 5 seconds { error() }
683                }
684        }
685        // pick next leader
686        leader := threads[ prng() % len(threads) ]
687        // wake every one
688        if ! exhaust {
689                for t in threads {
690                        if t != me { t.wake() }
691                }
692        }
693}
694Thread.wait() {
695        this.idx_seen := lead_idx
696        if exhaust { wait() }
697        else { yield() }
698}
699Thread.main() {
700        while !done  {
701                if leader == me { this.lead() }
702                else { this.wait() }
703        }
704}
705\end{cfa}
706\caption[Transfer Benchmark : Pseudo Code]{Transfer Benchmark : Pseudo Code}
707\label{fig:transfer:code}
708\end{figure}
709
710The experiment is designed to evaluate the short-term load-balancing of a scheduler.
711Indeed, schedulers where the runnable \ats are partitioned on the \procs may need to balance the \ats for this experiment to terminate.
712This problem occurs because the spinning \at is effectively preventing the \proc from running any other \at.
713In the semaphore variation, the number of runnable \ats eventually dwindles down to only the leader.
714This scenario is a simpler case to handle for schedulers since \procs eventually run out of work.
715In the yielding variation, the number of runnable \ats stays constant.
716This scenario is a harder case to handle because corrective measures must be taken even when work is available.
717Note, runtimes with preemption circumvent this problem by forcing the spinner to yield.
718In \CFA preemption was disabled as it only obfuscates the results.
719I am not aware of a method to disable preemption in Go.
720
721In both variations, the experiment effectively measures how long it takes for all \ats to run once after a given synchronization point.
722In an ideal scenario where the scheduler is strictly FIFO, every thread would run once after the synchronization and therefore the delay between leaders would be given by, $(CSL + SL) / (NP - 1)$,
723where $CSL$ is the context-switch latency, $SL$ is the cost for enqueueing and dequeuing a \at, and $NP$ is the number of \procs.
724However, if the scheduler allows \ats to run many times before other \ats are able to run once, this delay increases.
725The semaphore version is an approximation of strictly FIFO scheduling, where none of the \ats \emph{attempt} to run more than once.
726The benchmark effectively provides the fairness guarantee in this case.
727In the yielding version however, the benchmark provides no such guarantee, which means the scheduler has full responsibility and any unfairness is measurable.
728
729While this is an artificial scenario, in real-life it requires only a few simple pieces.
730The yielding version simply creates a scenario where a \at runs uninterrupted in a saturated system and the starvation has an easily measured impact.
731Hence, \emph{any} \at that runs uninterrupted for a significant period of time in a saturated system could lead to this kind of starvation.
732
733\subsection{Results}
734
735\begin{table}
736\caption[Transfer Benchmark on Intel and AMD]{Transfer Benchmark on Intel and AMD\smallskip\newline Average measurement of how long it takes for all \ats to acknowledge the leader \at.
737DNC stands for ``did not complete'', meaning that after 5 seconds of a new leader being decided, some \ats still had not acknowledged the new leader.}
738\label{fig:transfer:res}
739\setlength{\extrarowheight}{2pt}
740\setlength{\tabcolsep}{5pt}
741\begin{centering}
742\begin{tabular}{r | c | c | c | c | c | c | c | c}
743Machine   &                     \multicolumn{4}{c |}{Intel}                &          \multicolumn{4}{c}{AMD}             \\
744\cline{2-9}
745Variation & \multicolumn{2}{c|}{Park} & \multicolumn{2}{c |}{Yield} & \multicolumn{2}{c|}{Park} & \multicolumn{2}{c}{Yield} \\
746\cline{2-9}
747\procs    &      2      &      192   &      2      &      192      &      2      &      256   &      2      &      256    \\
748\hline
749\CFA      & 106 $\mu$& ~19.9 ms   & 68.4 $\mu$s & ~1.2 ms       & 174 $\mu$& ~28.4 ms   & 78.8~~$\mu$s& ~~1.21 ms   \\
750libfibre  & 127 $\mu$& ~33.5 ms   & DNC         & DNC           & 156 $\mu$& ~36.7 ms   & DNC         & DNC         \\
751Go        & 106 $\mu$& ~64.0 ms   & 24.6 ms     & 74.3 ms       & 271 $\mu$& 121.6 ms   & ~~1.21~ms   & 117.4 ms    \\
752Tokio     & 289 $\mu$& 180.6 ms   & DNC         & DNC           & 157 $\mu$& 111.0 ms   & DNC         & DNC
753\end{tabular}
754\end{centering}
755\end{table}
756
757Table~\ref{fig:transfer:res} shows the result for the transfer benchmark with 2 \procs and all \procs on the computer, where each experiment runs 100 \at per \proc.
758Note that the results here are only meaningful as a coarse measurement of fairness, beyond which small cost differences in the runtime and concurrent primitives begin to matter.
759As such, data points within the same order of magnitude are basically considered equal.
760That is, the takeaway of this experiment is the presence of very large differences.
761The semaphore variation is denoted ``Park'', where the number of \ats dwindles down as the new leader is acknowledged.
762The yielding variation is denoted ``Yield''.
763The experiment is only run for few and many \procs, since scaling is not the focus of this experiment.
764
765The first two columns show the results for the semaphore variation on Intel.
766While there are some differences in latencies, \CFA is consistently the fastest and Tokio the slowest, all runtimes achieve results that are fairly close.
767Again, this experiment is meant to highlight major differences so latencies within $10\times$ of each other are considered equal.
768
769Looking at the next two columns, the results for the yield variation on Intel, the story is very different.
770\CFA achieves better latencies, presumably due to no synchronization with the yield.
771Go does complete the experiment, but with drastically higher latency:
772latency at 2 \procs is $350\times$ higher than \CFA and $70\times$ higher at 192 \procs.
773This difference is because Go has a classic work-stealing scheduler, but it adds coarse-grain preemption
774, which interrupts the spinning leader after a period.
775Neither Libfibre or Tokio complete the experiment.
776Both runtimes also use classical work-stealing scheduling without preemption, and therefore, none of the work queues are ever emptied so no load balancing occurs.
777
778Looking now at the results for the AMD architecture, the results show effectively the same story.
779The first two columns show all runtime obtaining results well within $10\times$ of each other.
780The next two columns again show \CFA producing low latencies, while Go still has notably higher latency but the difference is less drastic on 2 \procs, where it produces a $15\times$ difference as opposed to a $100\times$ difference on 256 \procs.
781Neither Libfibre or Tokio complete the experiment.
782
783This experiments clearly demonstrates \CFA achieves significantly better fairness.
784The semaphore variation serves as a control, where all runtimes are expected to transfer leadership fairly quickly.
785Since \ats block after acknowledging the leader, this experiment effectively measures how quickly \procs can steal \ats from the \proc running the leader.
786Table~\ref{fig:transfer:res} shows that while Go and Tokio are slower using the semaphore, all runtimes achieve decent latency.
787
788However, the yielding variation shows an entirely different picture.
789Since libfibre and Tokio have a traditional work-stealing scheduler, \procs that have \ats on their local queues never steal from other \procs.
790The result is that the experiment simply does not complete for these runtimes.
791Without \procs stealing from the \proc running the leader, the experiment cannot terminate.
792Go manages to complete the experiment because it adds preemption on top of classic work-stealing.
793However, since preemption is fairly infrequent, it achieves significantly worst performance.
794In contrast, \CFA achieves equivalent performance in both variations, demonstrating very good fairness.
795Interestingly \CFA achieves better delays in the yielding version than the semaphore version, however, that is likely due to fairness being equivalent but removing the cost of the semaphores and idle sleep.
Note: See TracBrowser for help on using the repository browser.