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

ADTast-experimentalpthread-emulation
Last change on this file since 1fcbce7 was 1fcbce7, checked in by Peter A. Buhr <pabuhr@…>, 20 months ago

proofred chapter eval_micro

  • 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{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 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 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 unparking and the current \at 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%\end{figure}ll have a physical key so it's not urgent.
104\bigskip
105%\begin{figure}
106        \subfloat[][Throughput, 100 cycles per \proc]{
107                \resizebox{0.5\linewidth}{!}{
108                        \input{result.cycle.jax.ops.pstex_t}
109                }
110                \label{fig:cycle:jax:ops}
111        }
112        \subfloat[][Throughput, 1 cycle per \proc]{
113                \resizebox{0.5\linewidth}{!}{
114                        \input{result.cycle.low.jax.ops.pstex_t}
115                }
116                \label{fig:cycle:jax:low:ops}
117        }
118
119        \subfloat[][Scalability, 100 cycles per \proc]{
120                \resizebox{0.5\linewidth}{!}{
121                        \input{result.cycle.jax.ns.pstex_t}
122                }
123                \label{fig:cycle:jax:ns}
124        }
125        \subfloat[][Scalability, 1 cycle per \proc]{
126                \resizebox{0.5\linewidth}{!}{
127                        \input{result.cycle.low.jax.ns.pstex_t}
128                }
129                \label{fig:cycle:jax:low:ns}
130        }
131        \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.
132        For throughput, higher is better, for scalability, lower is better.
133        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.}
134        \label{fig:cycle:jax}
135\end{figure}
136
137\begin{figure}
138        \subfloat[][Throughput, 100 cycles per \proc]{
139                \resizebox{0.5\linewidth}{!}{
140                        \input{result.cycle.nasus.ops.pstex_t}
141                }
142                \label{fig:cycle:nasus:ops}
143        }
144        \subfloat[][Throughput, 1 cycle per \proc]{
145                \resizebox{0.5\linewidth}{!}{
146                        \input{result.cycle.low.nasus.ops.pstex_t}
147                }
148                \label{fig:cycle:nasus:low:ops}
149        }
150
151        \subfloat[][Scalability, 100 cycles per \proc]{
152                \resizebox{0.5\linewidth}{!}{
153                        \input{result.cycle.nasus.ns.pstex_t}
154                }
155                \label{fig:cycle:nasus:ns}
156        }
157        \subfloat[][Scalability, 1 cycle per \proc]{
158                \resizebox{0.5\linewidth}{!}{
159                        \input{result.cycle.low.nasus.ns.pstex_t}
160                }
161                \label{fig:cycle:nasus:low:ns}
162        }
163        \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.
164        For throughput, higher is better, for scalability, lower is better.
165        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.}
166        \label{fig:cycle:nasus}
167\end{figure}
168
169\subsection{Results}
170
171Figures~\ref{fig:cycle:jax} and \ref{fig:cycle:nasus} show the results for the cycle experiment on Intel and AMD, respectively.
172Looking 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.
173\CFA, Go and Tokio all obtain effectively the same throughput performance.
174Libfibre is slightly behind in this case but still scales decently.
175As 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.
176This effect even causes a decrease in throughput in libfibre's case.
177As expected, this pattern repeats again between \proc count 72 and 96.
178
179Looking 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.
180\CFA and Tokio obtain very similar results overall, but Tokio shows more variations in the results.
181Go achieves slightly better performance than \CFA and Tokio, but all three display significantly worst performance compared to the left column.
182This decrease in performance is likely due to the additional overhead of the idle-sleep mechanism.
183This 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.
184Indeed, unlike the left column, it is likely that the ready-queue is transiently empty, which likely triggers additional synchronization steps.
185Interestingly, libfibre achieves better performance with 1 cycle.
186
187Looking 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.
188Note the maximum of the Y-axis on Intel and AMD differ significantly.
189Looking 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.
190However, as the number of \procs grows higher, the results on AMD show notably more variability than on Intel.
191The 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.
192Looking 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.
193This result is different than on Intel, where Tokio behaved like \CFA rather than behaving like Go.
194Again, the same performance increase for libfibre is visible when running fewer \ats.
195Note, I did not investigate the libfibre performance boost for 1 cycle in this experiment.
196
197The conclusion from both architectures is that all of the compared runtime have fairly equivalent performance for this micro-benchmark.
198Clearly, the pathological case with 1 cycle per \proc can affect fairness algorithms managing mostly idle processors, \eg \CFA, but only at high core counts.
199For this case, \emph{any} helping is likely to cause a cascade of \procs running out of work and attempting to steal.
200For this experiment, the \CFA scheduler has achieved the goal of obtaining equivalent performance to other less fair schedulers.
201
202\section{Yield}
203
204For completeness, the classic yield benchmark is included.
205Here, the throughput is dominated by the mechanism used to handle the @yield@ function.
206Figure~\ref{fig:yield:code} shows pseudo code for this benchmark, where the cycle @wait/next.wake@ is replaced by @yield@.
207As mentioned, this benchmark may not be representative because of optimization shortcuts in @yield@.
208The 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.
209
210\begin{figure}
211\begin{cfa}
212Thread.main() {
213        count := 0
214        for {
215                @yield()@
216                count ++
217                if must_stop() { break }
218        }
219        global.count += count
220}
221\end{cfa}
222\caption[Yield Benchmark : Pseudo Code]{Yield Benchmark : Pseudo Code}
223\label{fig:yield:code}
224%\end{figure}
225\bigskip
226%\begin{figure}
227        \subfloat[][Throughput, 100 \ats per \proc]{
228                \resizebox{0.5\linewidth}{!}{
229                        \input{result.yield.jax.ops.pstex_t}
230                }
231                \label{fig:yield:jax:ops}
232        }
233        \subfloat[][Throughput, 1 \ats per \proc]{
234                \resizebox{0.5\linewidth}{!}{
235                \input{result.yield.low.jax.ops.pstex_t}
236                }
237                \label{fig:yield:jax:low:ops}
238        }
239
240        \subfloat[][Scalability, 100 \ats per \proc]{
241                \resizebox{0.5\linewidth}{!}{
242                \input{result.yield.jax.ns.pstex_t}
243                }
244                \label{fig:yield:jax:ns}
245        }
246        \subfloat[][Scalability, 1 \ats per \proc]{
247                \resizebox{0.5\linewidth}{!}{
248                \input{result.yield.low.jax.ns.pstex_t}
249                }
250                \label{fig:yield:jax:low:ns}
251        }
252        \caption[Yield Benchmark on Intel]{Yield Benchmark on Intel\smallskip\newline Throughput and scalability as a function of \proc count.
253        For throughput, higher is better, for scalability, lower is better.
254        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.}
255        \label{fig:yield:jax}
256\end{figure}
257
258\subsection{Results}
259
260Figures~\ref{fig:yield:jax} and \ref{fig:yield:nasus} show the results for the yield experiment on Intel and AMD, respectively.
261Looking 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.
262Note, the Y-axis on this graph is twice as large as the Intel cycle-graph.
263A visual glance between the left columns of the cycle and yield graphs confirms my claim that the yield benchmark is unreliable.
264\CFA has no special handling for @yield@, but this experiment requires less synchronization than the @cycle@ experiment.
265Hence, the @yield@ throughput and scalability graphs have similar shapes to the corresponding @cycle@ graphs.
266The only difference is sightly better performance for @yield@ because of less synchronization.
267Libfibre 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.
268Hence, libfibre behaves very differently in the cycle and yield benchmarks, with a 4 times increase in performance on the left column.
269Go has special handling for @yield@ by putting a yielding goroutine on a secondary global ready-queue, giving it lower priority.
270The result is that multiple \glspl{hthrd} contend for the global queue and performance suffers drastically.
271Hence, Go behaves very differently in the cycle and yield benchmarks, with a complete performance collapse in @yield@.
272Tokio 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.
273(I did not dig through the Rust code to ascertain the exact reason for the collapse.)
274Note that since there is no communication among \ats, locality problems are much less likely than for the cycle benchmark.
275This lack of communication is probably why the plateaus due to topology are not present.
276
277Looking 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.
278As 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.
279This result is to be expected since fewer \ats means \procs are more likely to run out of work.
280On the other hand, when only running 1 \at per \proc, libfibre optimizes further, and forgoes the context-switch entirely.
281This results in libfibre outperforming other runtimes even more, achieving 8 times more throughput than for @cycle@.
282Finally, Go and Tokio performance collapse is still the same with fewer \ats.
283The only exception is Tokio running on 24 \proc, deepening the mystery of its yielding mechanism further.
284
285\begin{figure}
286        \subfloat[][Throughput, 100 \ats per \proc]{
287                \resizebox{0.5\linewidth}{!}{
288                        \input{result.yield.nasus.ops.pstex_t}
289                }
290                \label{fig:yield:nasus:ops}
291        }
292        \subfloat[][Throughput, 1 \at per \proc]{
293                \resizebox{0.5\linewidth}{!}{
294                        \input{result.yield.low.nasus.ops.pstex_t}
295                }
296                \label{fig:yield:nasus:low:ops}
297        }
298
299        \subfloat[][Scalability, 100 \ats per \proc]{
300                \resizebox{0.5\linewidth}{!}{
301                        \input{result.yield.nasus.ns.pstex_t}
302                }
303                \label{fig:yield:nasus:ns}
304        }
305        \subfloat[][Scalability, 1 \at per \proc]{
306                \resizebox{0.5\linewidth}{!}{
307                        \input{result.yield.low.nasus.ns.pstex_t}
308                }
309                \label{fig:yield:nasus:low:ns}
310        }
311        \caption[Yield Benchmark on AMD]{Yield Benchmark on AMD\smallskip\newline Throughput and scalability as a function of \proc count.
312        For throughput, higher is better, for scalability, lower is better.
313        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.}
314        \label{fig:yield:nasus}
315\end{figure}
316
317Looking 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.
318Note that the maximum of the Y-axis on Intel and AMD differ less in @yield@ than @cycle@.
319Looking at the left column first, Figures~\ref{fig:yield:nasus:ops} and \ref{fig:yield:nasus:ns}, \CFA achieves very similar throughput and scaling.
320Libfibre still outpaces all other runtimes, but it encounter a performance hit at 64 \procs.
321This 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.
322Go and Tokio still display the same performance collapse as on Intel.
323Looking 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.
324At the high \ats count, the only difference is Libfibre's scaling and this difference disappears on the right column.
325This behaviour suggest whatever communication issue it encountered on the left is completely circumvented on the right.
326
327It is difficult to draw conclusions for this benchmark when runtime system treat @yield@ so differently.
328The 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.
329
330
331\section{Churn}
332
333The Cycle and Yield benchmark represent an \emph{easy} scenario for a scheduler, \eg an embarrassingly parallel application.
334In these benchmarks, \ats can be easily partitioned over the different \procs upfront and none of the \ats communicate with each other.
335
336The 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.
337With 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.
338This dequeuing results in either contention on the remote queue and/or \glspl{rmr} on the \at data structure.
339Hence, this benchmark has performance dominated by the cache traffic as \procs are constantly accessing each other's data.
340In 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.
341
342This benchmark uses a fixed-size array of counting semaphores.
343Each \at picks a random semaphore, @V@s it to unblock any waiting \at, and then @P@s (maybe blocks) the \at on the semaphore.
344This creates a flow where \ats push each other out of the semaphores before being pushed out themselves.
345For this benchmark to work, the number of \ats must be equal or greater than the number of semaphores plus the number of \procs;
346\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.
347Note, the nature of these semaphores mean the counter can go beyond 1, which can lead to nonblocking calls to @P@.
348Figure~\ref{fig:churn:code} shows pseudo code for this benchmark, where the @yield@ is replaced by @V@ and @P@.
349
350\begin{figure}
351\begin{cfa}
352Thread.main() {
353        count := 0
354        for {
355                r := random() % len(spots)
356                @spots[r].V()@
357                @spots[r].P()@
358                count ++
359                if must_stop() { break }
360        }
361        global.count += count
362}
363\end{cfa}
364\caption[Churn Benchmark : Pseudo Code]{Churn Benchmark : Pseudo Code}
365\label{fig:churn:code}
366%\end{figure}
367\bigskip
368%\begin{figure}
369        \subfloat[][Throughput, 100 \ats per \proc]{
370                \resizebox{0.5\linewidth}{!}{
371                        \input{result.churn.jax.ops.pstex_t}
372                }
373                \label{fig:churn:jax:ops}
374        }
375        \subfloat[][Throughput, 2 \ats per \proc]{
376                \resizebox{0.5\linewidth}{!}{
377                        \input{result.churn.low.jax.ops.pstex_t}
378                }
379                \label{fig:churn:jax:low:ops}
380        }
381
382        \subfloat[][Scalability, 100 \ats per \proc]{
383                \resizebox{0.5\linewidth}{!}{
384                        \input{result.churn.jax.ns.pstex_t}
385                }
386                \label{fig:churn:jax:ns}
387        }
388        \subfloat[][Scalability, 2 \ats per \proc]{
389                \resizebox{0.5\linewidth}{!}{
390                        \input{result.churn.low.jax.ns.pstex_t}
391                }
392                \label{fig:churn:jax:low:ns}
393        }
394        \caption[Churn Benchmark on Intel]{Churn Benchmark on Intel\smallskip\newline Throughput and scalability of the Churn on the benchmark on the Intel machine.
395        For throughput, higher is better, for scalability, lower is better.
396        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.}
397        \label{fig:churn:jax}
398\end{figure}
399
400\subsection{Results}
401
402Figures~\ref{fig:churn:jax} and Figure~\ref{fig:churn:nasus} show the results for the churn experiment on Intel and AMD, respectively.
403Looking 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 have, and all runtimes obtain fairly similar throughput for most \proc counts.
404\CFA does very well on a single \proc but quickly loses its advantage over the other runtimes.
405As expected, it scales decently up to 48 \procs, drops from 48 to 72 \procs, and then plateaus.
406Tokio 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.
407Libfibre obtains effectively the same results as Tokio with slightly less scaling, \ie the scaling curve is the same but with slightly lower values.
408Finally, Go gets the most peculiar results, scaling worst than other runtimes until 48 \procs.
409At 72 \procs, the results of the Go runtime vary significantly, sometimes scaling sometimes plateauing.
410However, beyond this point Go keeps this level of variation but does not scale further in any of the runs.
411
412Throughput and scalability is notably worst for all runtimes than the previous benchmarks since there is inherently more communication between processors.
413Indeed, none of the runtimes reach 40 million operations per second while in the cycle benchmark all but libfibre reached 400 million operations per second.
414Figures~\ref{fig:churn:jax:ns} and \ref{fig:churn:jax:low:ns} show that for all \proc count, all runtimes produce poor scaling.
415However, 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.
416At this point, the benchmark is dominated by inter-socket communication costs for all runtimes.
417
418An interesting aspect to note here is that the runtimes differ in how they handle this situation.
419Indeed, 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.
420\CFA, Tokio and Go all use the approach of unparking to the local \proc, while Libfibre unparks to the remote \proc.
421In this particular benchmark, the inherent chaos of the benchmark, in addition to small memory footprint, means neither approach wins over the other.
422
423Looking 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.
424\CFA outperforms other runtimes by a minuscule margin.
425Libfibre follows very closely behind with basically the same performance and scaling.
426Tokio maintains effectively the same curve shapes as \CFA and libfibre, but it incurs extra costs for all \proc counts.
427% As a result it is slightly outperformed by \CFA and libfibre.
428While Go maintains overall similar results to the others, it again encounters significant variation at high \proc counts.
429Inexplicably resulting in super-linear scaling for some runs, \ie the scalability curves displays a negative slope.
430
431Interestingly, unlike the cycle benchmark, running with fewer \ats does not produce drastically different results.
432In fact, the overall throughput stays almost exactly the same on the left and right column.
433
434\begin{figure}
435        \subfloat[][Throughput, 100 \ats per \proc]{
436                \resizebox{0.5\linewidth}{!}{
437                        \input{result.churn.nasus.ops.pstex_t}
438                }
439                \label{fig:churn:nasus:ops}
440        }
441        \subfloat[][Throughput, 2 \ats per \proc]{
442                \resizebox{0.5\linewidth}{!}{
443                        \input{result.churn.low.nasus.ops.pstex_t}
444                }
445                \label{fig:churn:nasus:low:ops}
446        }
447
448        \subfloat[][Scalability, 100 \ats per \proc]{
449                \resizebox{0.5\linewidth}{!}{
450                        \input{result.churn.nasus.ns.pstex_t}
451                }
452                \label{fig:churn:nasus:ns}
453        }
454        \subfloat[][Scalability, 2 \ats per \proc]{
455                \resizebox{0.5\linewidth}{!}{
456                        \input{result.churn.low.nasus.ns.pstex_t}
457                }
458                \label{fig:churn:nasus:low:ns}
459        }
460        \caption[Churn Benchmark on AMD]{Churn Benchmark on AMD\smallskip\newline Throughput and scalability of the Churn on the benchmark on the AMD machine.
461        For throughput, higher is better, for scalability, lower is better.
462        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.}
463        \label{fig:churn:nasus}
464\end{figure}
465
466
467Looking now at the results for the AMD architecture, Figure~\ref{fig:churn:nasus}, the results show a somewhat different story.
468Looking 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.
469\CFA suffers particular from a larger variations at higher \proc counts, but largely outperforms the other runtimes.
470Go still produces intriguing results in this case and even more intriguingly, the results have fairly low variation.
471
472One possible explanation for Go's difference is that it has very few available concurrent primitives, so a channel is substituted for a semaphore.
473On paper a semaphore can be replaced by a channel, and with zero-sized objects passed through the channel, equivalent performance could be expected.
474However, in practice, there are implementation difference between the two, \eg if the semaphore count can get somewhat high so object accumulate in the channel.
475Note that this substitution is also made in the cycle benchmark;
476however, in that context, it did not have a notable impact.
477
478As second possible explanation is that Go may use the heap when allocating variables based on the result of escape analysis of the code.
479It is possible for variables that could be placed on the stack to instead be placed on the heap.
480This placement could cause extra pointer chasing in the benchmark, heightening locality effects.
481Depending on how the heap is structure, this could also lead to false sharing.
482I did not investigate what causes these unusual results.
483
484Looking 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.
485\CFA, Libfibre and Tokio all have very close results.
486Go still suffers from poor scalability but is now unusual in a different way.
487While it obtains effectively constant performance regardless of \proc count, this ``sequential'' performance is higher than the other runtimes for low \proc count.
488Up to 32 \procs, after which the other runtime manage to outscale Go.
489
490In conclusion, the objective of this benchmark is to demonstrate that unparking \ats from remote \procs does not cause too much contention on the local queues.
491Indeed, the fact that most runtimes achieve some scaling between various \proc count demonstrate migrations do not need to be serialized.
492Again these result demonstrate \CFA achieves satisfactory performance with respect to the other runtimes.
493
494\section{Locality}
495
496As mentioned in the churn benchmark, when unparking a \at, it is possible to either unpark to the local or remote ready-queue.\footnote{
497It is also possible to unpark to a third unrelated ready-queue, but without additional knowledge about the situation, it is likely to degrade performance.}
498The locality experiment includes two variations of the churn benchmark, where a data array is added.
499In both variations, before @V@ing the semaphore, each \at increments random cells inside the data array by calling a @work@ function.
500In the noshare variation, the array is not passed on and each thread continuously accesses its private array.
501In 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.
502Figure~\ref{fig:locality:code} shows pseudo code for this benchmark.
503
504The objective here is to highlight the different decision made by the runtime when unparking.
505Since each thread unparks a random semaphore, it means that it is unlikely that a \at is unparked from the last \proc it ran on.
506In the noshare variation, unparking the \at on the local \proc is an appropriate choice since the data was last modified on that \proc.
507In the shared variation, unparking the \at on a remote \proc is an appropriate choice.
508\todo{PAB: I changed these sentences around.}
509
510The expectation for this benchmark is to see a performance inversion, where runtimes fare notably better in the variation which matches their unparking policy.
511This decision should lead to \CFA, Go and Tokio achieving better performance in the share variation while libfibre achieves better performance in noshare.
512Indeed, \CFA, Go and Tokio have the default policy of unparking \ats on the local \proc, where as libfibre has the default policy of unparking \ats wherever they last ran.
513
514\begin{figure}
515\newsavebox{\myboxA}
516\newsavebox{\myboxB}
517
518\begin{lrbox}{\myboxA}
519\begin{cfa}[tabsize=3]
520Thread.main() {
521        count := 0
522        for {
523                r := random() % len(spots)
524                // go through the array
525                @work( a )@
526
527                spots[r].V()
528                spots[r].P()
529                count ++
530                if must_stop() { break }
531        }
532        global.count += count
533}
534\end{cfa}
535\end{lrbox}
536
537\begin{lrbox}{\myboxB}
538\begin{cfa}[tabsize=3]
539Thread.main() {
540        count := 0
541        for {
542                r := random() % len(spots)
543                // go through the array
544                @work( a )@
545                // pass array to next thread
546                spots[r].V( @a@ )
547                @a = @spots[r].P()
548                count ++
549                if must_stop() { break }
550        }
551        global.count += count
552}
553\end{cfa}
554\end{lrbox}
555
556\subfloat[Noshare]{\label{fig:locality:code:T1}\usebox\myboxA}
557\hspace{3pt}
558\vrule
559\hspace{3pt}
560\subfloat[Share]{\label{fig:locality:code:T1}\usebox\myboxB}
561
562\caption[Locality Benchmark : Pseudo Code]{Locality Benchmark : Pseudo Code}
563\label{fig:locality:code}
564\end{figure}
565
566\subsection{Results}
567
568Figures~\ref{fig:locality:jax} and \ref{fig:locality:nasus} show the results for the locality experiment on Intel and AMD, respectively.
569In 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.
570Looking 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.
571\CFA and Tokio slightly outperform libfibre, as expected, based on their \ats placement approach.
572\CFA and Tokio both unpark locally and do not suffer cache misses on the transferred array.
573Libfibre on the other hand unparks remotely, and as such the unparked \at is likely to miss on the shared data.
574Go trails behind in this experiment, presumably for the same reasons that were observable in the churn benchmark.
575Otherwise, the results are similar to the churn benchmark, with lower throughput due to the array processing.
576As 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.
577
578\begin{figure}
579        \subfloat[][Throughput share]{
580                \resizebox{0.5\linewidth}{!}{
581                        \input{result.locality.share.jax.ops.pstex_t}
582                }
583                \label{fig:locality:jax:share:ops}
584        }
585        \subfloat[][Throughput noshare]{
586                \resizebox{0.5\linewidth}{!}{
587                        \input{result.locality.noshare.jax.ops.pstex_t}
588                }
589                \label{fig:locality:jax:noshare:ops}
590        }
591
592        \subfloat[][Scalability share]{
593                \resizebox{0.5\linewidth}{!}{
594                        \input{result.locality.share.jax.ns.pstex_t}
595                }
596                \label{fig:locality:jax:share:ns}
597        }
598        \subfloat[][Scalability noshare]{
599                \resizebox{0.5\linewidth}{!}{
600                        \input{result.locality.noshare.jax.ns.pstex_t}
601                }
602                \label{fig:locality:jax:noshare:ns}
603        }
604        \caption[Locality Benchmark on Intel]{Locality Benchmark on Intel\smallskip\newline Throughput and scalability as a function of \proc count.
605        For throughput, higher is better, for scalability, lower is better.
606        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.}
607        \label{fig:locality:jax}
608\end{figure}
609
610\begin{figure}
611        \subfloat[][Throughput share]{
612                \resizebox{0.5\linewidth}{!}{
613                        \input{result.locality.share.nasus.ops.pstex_t}
614                }
615                \label{fig:locality:nasus:share:ops}
616        }
617        \subfloat[][Throughput noshare]{
618                \resizebox{0.5\linewidth}{!}{
619                        \input{result.locality.noshare.nasus.ops.pstex_t}
620                }
621                \label{fig:locality:nasus:noshare:ops}
622        }
623
624        \subfloat[][Scalability share]{
625                \resizebox{0.5\linewidth}{!}{
626                        \input{result.locality.share.nasus.ns.pstex_t}
627                }
628                \label{fig:locality:nasus:share:ns}
629        }
630        \subfloat[][Scalability noshare]{
631                \resizebox{0.5\linewidth}{!}{
632                        \input{result.locality.noshare.nasus.ns.pstex_t}
633                }
634                \label{fig:locality:nasus:noshare:ns}
635        }
636        \caption[Locality Benchmark on AMD]{Locality Benchmark on AMD\smallskip\newline Throughput and scalability as a function of \proc count.
637        For throughput, higher is better, for scalability, lower is better.
638        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.}
639        \label{fig:locality:nasus}
640\end{figure}
641
642Looking 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.
643The graphs show the expected performance inversion where libfibre now outperforms \CFA and Tokio.
644Indeed, 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.
645Results show both are amortized fairly well in this case.
646\CFA and Tokio both unpark locally and as a result suffer a marginal performance degradation from the cache miss on the array.
647
648Looking at the results for the AMD architecture, Figure~\ref{fig:locality:nasus}, shows results similar to the Intel.
649Again overall performance is higher and slightly more variation is visible.
650Looking 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.
651This advantage is expected from the AMD server with its smaller and more narrow caches that magnify the costs of processing the array.
652Go still has the same poor performance as on Intel.
653
654Finally 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.
655Go still has the same poor performance.
656
657Overall, this benchmark mostly demonstrates the two options available when unparking a \at.
658Depending on the workload, either of these options can be the appropriate one.
659Since it is prohibitively difficult to dynamically detect which approach is appropriate, all runtimes much choose one of the two and live with the consequences.
660
661Once 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.
662
663\section{Transfer}
664The last benchmark is more of an experiment than a benchmark.
665It tests the behaviour of the schedulers for a misbehaved workload.
666In this workload, one \at is selected at random to be the leader.
667The leader then spins in a tight loop until it has observed that all other \ats have acknowledged its leadership.
668The leader \at then picks a new \at to be the next leader and the cycle repeats.
669The benchmark comes in two variations for the non-leader \ats:
670once they acknowledged the leader, they either block on a semaphore or spin yielding.
671Figure~\ref{fig:transfer:code} shows pseudo code for this benchmark.
672
673\begin{figure}
674\begin{cfa}
675Thread.lead() {
676        this.idx_seen = ++lead_idx
677        if lead_idx > stop_idx {
678                done := true
679                return
680        }
681        // Wait for everyone to acknowledge my leadership
682        start: = timeNow()
683        for t in threads {
684                while t.idx_seen != lead_idx {
685                        asm pause
686                        if (timeNow() - start) > 5 seconds { error() }
687                }
688        }
689        // pick next leader
690        leader := threads[ prng() % len(threads) ]
691        // wake every one
692        if ! exhaust {
693                for t in threads {
694                        if t != me { t.wake() }
695                }
696        }
697}
698Thread.wait() {
699        this.idx_seen := lead_idx
700        if exhaust { wait() }
701        else { yield() }
702}
703Thread.main() {
704        while !done  {
705                if leader == me { this.lead() }
706                else { this.wait() }
707        }
708}
709\end{cfa}
710\caption[Transfer Benchmark : Pseudo Code]{Transfer Benchmark : Pseudo Code}
711\label{fig:transfer:code}
712\end{figure}
713
714The experiment is designed to evaluate the short-term load-balancing of a scheduler.
715Indeed, schedulers where the runnable \ats are partitioned on the \procs may need to balance the \ats for this experiment to terminate.
716This problem occurs because the spinning \at is effectively preventing the \proc from running any other \at.
717In the semaphore variation, the number of runnable \ats eventually dwindles down to only the leader.
718This scenario is a simpler case to handle for schedulers since \procs eventually run out of work.
719In the yielding variation, the number of runnable \ats stays constant.
720This scenario is a harder case to handle because corrective measures must be taken even when work is available.
721Note, runtimes with preemption circumvent this problem by forcing the spinner to yield.
722
723In both variations, the experiment effectively measures how long it takes for all \ats to run once after a given synchronization point.
724In 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)$,
725where $CSL$ is the context-switch latency, $SL$ is the cost for enqueueing and dequeuing a \at, and $NP$ is the number of \procs.
726However, if the scheduler allows \ats to run many times before other \ats are able to run once, this delay increases.
727The semaphore version is an approximation of strictly FIFO scheduling, where none of the \ats \emph{attempt} to run more than once.
728The benchmark effectively provides the fairness guarantee in this case.
729In the yielding version however, the benchmark provides no such guarantee, which means the scheduler has full responsibility and any unfairness is measurable.
730
731While this is an artificial scenario, in real-life it requires only a few simple pieces.
732The yielding version simply creates a scenario where a \at runs uninterrupted in a saturated system and the starvation has an easily measured impact.
733Hence, \emph{any} \at that runs uninterrupted for a significant period of time in a saturated system could lead to this kind of starvation.
734
735\subsection{Results}
736
737\begin{table}
738\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.
739DNC 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.}
740\label{fig:transfer:res}
741\setlength{\extrarowheight}{2pt}
742\setlength{\tabcolsep}{5pt}
743\begin{centering}
744\begin{tabular}{r | c | c | c | c | c | c | c | c}
745Machine   &                     \multicolumn{4}{c |}{Intel}                &          \multicolumn{4}{c}{AMD}             \\
746\cline{2-9}
747Variation & \multicolumn{2}{c|}{Park} & \multicolumn{2}{c |}{Yield} & \multicolumn{2}{c|}{Park} & \multicolumn{2}{c}{Yield} \\
748\cline{2-9}
749\procs    &      2      &      192   &      2      &      192      &      2      &      256   &      2      &      256    \\
750\hline
751\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   \\
752libfibre  & 127 $\mu$& ~33.5 ms   & DNC         & DNC           & 156 $\mu$& ~36.7 ms   & DNC         & DNC         \\
753Go        & 106 $\mu$& ~64.0 ms   & 24.6 ms     & 74.3 ms       & 271 $\mu$& 121.6 ms   & ~~1.21~ms   & 117.4 ms    \\
754Tokio     & 289 $\mu$& 180.6 ms   & DNC         & DNC           & 157 $\mu$& 111.0 ms   & DNC         & DNC
755\end{tabular}
756\end{centering}
757\end{table}
758
759Table~\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.
760Note 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.
761As such, data points within the same order of magnitude are basically considered equal.
762That is, the takeaway of this experiment is the presence of very large differences.
763The semaphore variation is denoted ``Park'', where the number of \ats dwindles down as the new leader is acknowledged.
764The yielding variation is denoted ``Yield''.
765The experiment is only run for many \procs, since scaling is not the focus of this experiment.
766
767The first two columns show the results for the semaphore variation on Intel.
768While there are some differences in latencies, \CFA is consistently the fastest and Tokio the slowest, all runtimes achieve results that are fairly close.
769Again, this experiment is meant to highlight major differences so latencies within $10\times$ of each other are considered equal.
770
771Looking at the next two columns, the results for the yield variation on Intel, the story is very different.
772\CFA achieves better latencies, presumably due to no synchronization with the yield.
773\todo{PAB: what about \CFA preemption? How does that come into play for your scheduler?}
774Go does complete the experiment, but with drastically higher latency:
775latency at 2 \procs is $350\times$ higher than \CFA and $70\times$ higher at 192 \procs.
776This difference is because Go has a classic work-stealing scheduler, but it adds coarse-grain preemption\footnote{
777Preemption is done at the function prolog when the goroutine's stack is increasing;
778whereas \CFA uses fine-grain preemption between any two instructions.}
779, which interrupts the spinning leader after a period.
780Neither Libfibre or Tokio complete the experiment.
781Both runtimes also use classical work-stealing scheduling without preemption, and therefore, none of the work queues are ever emptied so no load balancing occurs.
782
783Looking now at the results for the AMD architecture, the results show effectively the same story.
784The first two columns show all runtime obtaining results well within $10\times$ of each other.
785The 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.
786Neither Libfibre or Tokio complete the experiment.
787
788This experiments clearly demonstrates \CFA achieves significantly better fairness.
789The semaphore variation serves as a control, where all runtimes are expected to transfer leadership fairly quickly.
790Since \ats block after acknowledging the leader, this experiment effectively measures how quickly \procs can steal \ats from the \proc running the leader.
791Table~\ref{fig:transfer:res} shows that while Go and Tokio are slower using the semaphore, all runtimes achieve decent latency.
792
793However, the yielding variation shows an entirely different picture.
794Since libfibre and Tokio have a traditional work-stealing scheduler, \procs that have \ats on their local queues never steal from other \procs.
795The result is that the experiment simply does not complete for these runtimes.
796Without \procs stealing from the \proc running the leader, the experiment cannot terminate.
797Go manages to complete the experiment because it adds preemption on top of classic work-stealing.
798However, since preemption is fairly infrequent, it achieves significantly worst performance.
799In contrast, \CFA achieves equivalent performance in both variations, demonstrating very good fairness.
800Interestingly \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.