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

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

Filled up the eval micro section

  • Property mode set to 100644
File size: 30.2 KB
Line 
1\chapter{Micro-Benchmarks}\label{microbench}
2
3The first step in evaluating this work is to test-out small controlled cases to ensure the basics work properly.
4This chapter presents five different experimental setup, evaluating some of the basic features of \CFA's scheduler.
5
6\section{Benchmark Environment}
7All benchmarks are run on two distinct hardware platforms.
8\begin{description}
9\item[AMD] is a server with two AMD EPYC 7662 CPUs and 256GB of DDR4 RAM.
10The 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}.
11Each CPU has 4 MB, 64 MB and 512 MB of L1, L2 and L3 caches, respectively.
12Each 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}.
13The server runs Ubuntu 20.04.2 LTS on top of Linux Kernel 5.8.0-55.
14
15\item[Intel] is a server with four Intel Xeon Platinum 8160 CPUs and 384GB of DDR4 RAM.
16The 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}.
17Each CPU has 3 MB, 96 MB and 132 MB of L1, L2 and L3 caches respectively.
18Each 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}.
19The server runs Ubuntu 20.04.2 LTS on top of Linux Kernel 5.8.0-55.
20\end{description}
21
22For all benchmarks, @taskset@ is used to limit the experiment to 1 NUMA Node with no hyper threading.
23If more \glspl{hthrd} are needed, then 1 NUMA Node with hyperthreading is used.
24If still more \glspl{hthrd} are needed, then the experiment is limited to as few NUMA Nodes as needed.
25
26The limited sharing of the last-level cache on the AMD machine is markedly different than the Intel machine.
27Indeed, 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 still incur high latency.
28
29
30\section{Cycling latency}
31\begin{figure}
32        \centering
33        \input{cycle.pstex_t}
34        \caption[Cycle benchmark]{Cycle benchmark\smallskip\newline Each \at unparks the next \at in the cycle before parking itself.}
35        \label{fig:cycle}
36\end{figure}
37The most basic evaluation of any ready queue is to evaluate the latency needed to push and pop one element from the ready queue.
38Since these two operation also describe a @yield@ operation, many systems use this operation as the most basic benchmark.
39However, yielding can be treated as a special case by optimizing it away since the number of ready \ats does not change.
40Not all systems perform this optimization, but those that do have an artificial performance benefit because the yield becomes a \emph{nop}.
41For this reason, I chose a different first benchmark, called \newterm{Cycle Benchmark}.
42This 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.
43At runtime, each \at unparks the next \at before parking itself.
44Unparking the next \at pushes that \at onto the ready queue while the ensuing park leads to a \at being popped from the ready queue.
45
46Hence, the underlying runtime cannot rely on the number of ready \ats staying constant over the duration of the experiment.
47In 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.
48That is, the runtime cannot anticipate that the current task will immediately park.
49As 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.
50Every runtime system must handle this race and cannot optimized away the ready-queue pushes and pops.
51To 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.
52(Note, an unpark is like a V on a semaphore, so the subsequent park (P) may not block.)
53Finally, to further mitigate any underlying push/pop optimizations, especially on SMP machines, multiple rings are created in the experiment.
54
55Figure~\ref{fig:cycle:code} shows the pseudo code for this benchmark.
56There 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.
57
58\begin{figure}
59\begin{cfa}
60Thread.main() {
61        count := 0
62        for {
63                @this.next.wake()@
64                @wait()@
65                count ++
66                if must_stop() { break }
67        }
68        global.count += count
69}
70\end{cfa}
71\caption[Cycle Benchmark : Pseudo Code]{Cycle Benchmark : Pseudo Code}
72\label{fig:cycle:code}
73\end{figure}
74
75\subsection{Results}
76\begin{figure}
77        \subfloat[][Throughput, 100 cycles per \proc]{
78                \resizebox{0.5\linewidth}{!}{
79                        \input{result.cycle.jax.ops.pstex_t}
80                }
81                \label{fig:cycle:jax:ops}
82        }
83        \subfloat[][Throughput, 1 cycle per \proc]{
84                \resizebox{0.5\linewidth}{!}{
85                        \input{result.cycle.low.jax.ops.pstex_t}
86                }
87                \label{fig:cycle:jax:low:ops}
88        }
89
90        \subfloat[][Scalability, 100 cycles per \proc]{
91                \resizebox{0.5\linewidth}{!}{
92                        \input{result.cycle.jax.ns.pstex_t}
93                }
94                \label{fig:cycle:jax:ns}
95        }
96        \subfloat[][Scalability, 1 cycle per \proc]{
97                \resizebox{0.5\linewidth}{!}{
98                        \input{result.cycle.low.jax.ns.pstex_t}
99                }
100                \label{fig:cycle:jax:low:ns}
101        }
102        \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 count. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
103        \label{fig:cycle:jax}
104\end{figure}
105
106\begin{figure}
107        \subfloat[][Throughput, 100 cycles per \proc]{
108                \resizebox{0.5\linewidth}{!}{
109                        \input{result.cycle.nasus.ops.pstex_t}
110                }
111                \label{fig:cycle:nasus:ops}
112        }
113        \subfloat[][Throughput, 1 cycle per \proc]{
114                \resizebox{0.5\linewidth}{!}{
115                        \input{result.cycle.low.nasus.ops.pstex_t}
116                }
117                \label{fig:cycle:nasus:low:ops}
118        }
119
120        \subfloat[][Scalability, 100 cycles per \proc]{
121                \resizebox{0.5\linewidth}{!}{
122                        \input{result.cycle.nasus.ns.pstex_t}
123                }
124                \label{fig:cycle:nasus:ns}
125        }
126        \subfloat[][Scalability, 1 cycle per \proc]{
127                \resizebox{0.5\linewidth}{!}{
128                        \input{result.cycle.low.nasus.ns.pstex_t}
129                }
130                \label{fig:cycle:nasus:low:ns}
131        }
132        \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 count. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
133        \label{fig:cycle:nasus}
134\end{figure}
135Figure~\ref{fig:cycle:jax} and Figure~\ref{fig:cycle:nasus} shows the throughput as a function of \proc count on Intel and AMD respectively, where each cycle has 5 \ats.
136The graphs show traditional throughput on the top row and \newterm{scalability} on the bottom row.
137Where scalability uses the same data but the Y axis is calculated as the number of \procs over the throughput.
138In 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.
139The left column shows results for 100 cycles per \proc, enough cycles to always keep every \proc busy.
140The right column shows results for only 1 cycle per \proc, where the ready queues are expected to be near empty at all times.
141The distinction 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.
142
143The performance goal of \CFA is to obtain equivalent performance to other, less fair schedulers and that is what results show.
144Figure~\ref{fig:cycle:jax:ops} and \ref{fig:cycle:jax:ns} show very good throughput and scalability for all runtimes.
145The experimental setup prioritizes running on 2 \glspl{hthrd} per core before running on multiple sockets.
146The effect of that setup is seen from 25 to 48 \procs, running on 24 core with 2 \glspl{hthrd} per core.
147This effect is again repeated from 73 and 96 \procs, where it happens on the second CPU.
148When running only a single cycle, most runtime achieve lower throughput because of the idle-sleep mechanism.
149
150Figure~\ref{fig:cycle:nasus} show effectively the same story happening on AMD as it does on Intel.
151The different performance bumps due to cache topology happen at different locations and there is a little more variability.
152However, in all cases \CFA is still competitive with other runtimes.
153
154
155\section{Yield}
156For completion, the classic yield benchmark is included.
157This benchmark is simpler than the cycle test: it creates many \ats that call @yield@.
158As mentioned, this benchmark may not be representative because of optimization shortcuts in @yield@.
159The 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.
160This scenario can put a strain on the idle-sleep handling compared to scenarios where there is plenty of work.
161Figure~\ref{fig:yield:code} shows pseudo code for this benchmark, where the @wait/next.wake@ is replaced by @yield@.
162
163\begin{figure}
164\begin{cfa}
165Thread.main() {
166        count := 0
167        for {
168                @yield()@
169                count ++
170                if must_stop() { break }
171        }
172        global.count += count
173}
174\end{cfa}
175\caption[Yield Benchmark : Pseudo Code]{Yield Benchmark : Pseudo Code}
176\label{fig:yield:code}
177\end{figure}
178
179\subsection{Results}
180\begin{figure}
181        \subfloat[][Throughput, 100 \ats per \proc]{
182                \resizebox{0.5\linewidth}{!}{
183                        \input{result.yield.jax.ops.pstex_t}
184                }
185                \label{fig:yield:jax:ops}
186        }
187        \subfloat[][Throughput, 1 \ats per \proc]{
188                \resizebox{0.5\linewidth}{!}{
189                \input{result.yield.low.jax.ops.pstex_t}
190                }
191                \label{fig:yield:jax:low:ops}
192        }
193
194        \subfloat[][Scalability, 100 \ats per \proc]{
195                \resizebox{0.5\linewidth}{!}{
196                \input{result.yield.jax.ns.pstex_t}
197                }
198                \label{fig:yield:jax:ns}
199        }
200        \subfloat[][Scalability, 1 \ats per \proc]{
201                \resizebox{0.5\linewidth}{!}{
202                \input{result.yield.low.jax.ns.pstex_t}
203                }
204                \label{fig:yield:jax:low:ns}
205        }
206        \caption[Yield Benchmark on Intel]{Yield Benchmark on Intel\smallskip\newline Throughput and Scalability as a function of \proc count, using 1 \ats per \proc. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
207        \label{fig:yield:jax}
208\end{figure}
209
210\begin{figure}
211        \subfloat[][Throughput, 100 \ats per \proc]{
212                \resizebox{0.5\linewidth}{!}{
213                        \input{result.yield.nasus.ops.pstex_t}
214                }
215                \label{fig:yield:nasus:ops}
216        }
217        \subfloat[][Throughput, 1 \at per \proc]{
218                \resizebox{0.5\linewidth}{!}{
219                        \input{result.yield.low.nasus.ops.pstex_t}
220                }
221                \label{fig:yield:nasus:low:ops}
222        }
223
224        \subfloat[][Scalability, 100 \ats per \proc]{
225                \resizebox{0.5\linewidth}{!}{
226                        \input{result.yield.nasus.ns.pstex_t}
227                }
228                \label{fig:yield:nasus:ns}
229        }
230        \subfloat[][Scalability, 1 \at per \proc]{
231                \resizebox{0.5\linewidth}{!}{
232                        \input{result.yield.low.nasus.ns.pstex_t}
233                }
234                \label{fig:yield:nasus:low:ns}
235        }
236        \caption[Yield Benchmark on AMD]{Yield Benchmark on AMD\smallskip\newline Throughput and Scalability as a function of \proc count, using 1 \ats per \proc. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
237        \label{fig:yield:nasus}
238\end{figure}
239Figure~\ref{fig:yield:jax} shows the throughput as a function of \proc count on Intel.
240It is fairly obvious why I claim this benchmark is more artificial.
241The throughput is dominated by the mechanism used to handle the @yield@.
242\CFA does not have special handling for @yield@ and achieves very similar performance to the cycle benchmark.
243Libfibre uses the fact that @yield@ doesn't change the number of ready fibres and by-passes the idle-sleep mechanism entirely, producing significantly better throughput.
244Go puts yielding goroutines on a secondary global ready-queue, giving them lower priority.
245The result is that multiple \glspl{hthrd} contend for the global queue and performance suffers drastically.
246Based on the scalability, Tokio obtains the same poor performance and therefore it is likely it handles @yield@ in a similar fashion.
247
248When the number of \ats is reduce to 1 per \proc, the cost of idle sleep also comes into play in a very significant way.
249If anything causes a \at migration, where two \ats end-up on the same ready-queue, work-stealing will start occuring and cause every \at to shuffle around.
250In the process, several \procs can go to sleep transiently if they fail to find where the \ats were shuffled to.
251In \CFA, spurious bursts of latency can trick a \proc into helping, triggering this effect.
252However, since user-level threading with equal number of \ats and \procs is a somewhat degenerate case, especially when ctxswitching very often, this result is not particularly meaningful and is only included for completness.
253
254Again, Figure~\ref{fig:yield:nasus} show effectively the same story happening on AMD as it does on Intel.
255\CFA fairs slightly better with many \ats per \proc, but the performance is satisfactory on both architectures.
256
257Since \CFA obtains the same satisfactory performance as the previous benchmark this is still a success, albeit a less meaningful one.
258
259
260\section{Churn}
261The Cycle and Yield benchmark represent an \emph{easy} scenario for a scheduler, \eg an embarrassingly parallel application.
262In these benchmarks, \ats can be easily partitioned over the different \procs upfront and none of the \ats communicate with each other.
263
264The Churn benchmark represents more chaotic executions, where there is more communication among \ats but no relation between the last \proc on which a \at ran and blocked and the \proc that subsequently unblocks it.
265With 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 global queue.
266This dequeuing results in either contention on the remote queue and/or \glspl{rmr} on \at data structure.
267In either case, this benchmark aims to measure how well each scheduler handles these cases, since both cases can lead to performance degradation if not handled correctly.
268
269This benchmark uses a fixed-size array of counting semaphores.
270Each \at picks a random semaphore, @V@s it to unblock any \at waiting, and then @P@s on the semaphore.
271This creates a flow where \ats push each other out of the semaphores before being pushed out themselves.
272For this benchmark to work, the number of \ats must be equal or greater than the number of semaphores plus the number of \procs.
273Note, the nature of these semaphores mean the counter can go beyond 1, which can lead to nonblocking calls to @P@.
274Figure~\ref{fig:churn:code} shows pseudo code for this benchmark, where the @yield@ is replaced by @V@ and @P@.
275
276\begin{figure}
277\begin{cfa}
278Thread.main() {
279        count := 0
280        for {
281                r := random() % len(spots)
282                @spots[r].V()@
283                @spots[r].P()@
284                count ++
285                if must_stop() { break }
286        }
287        global.count += count
288}
289\end{cfa}
290\caption[Churn Benchmark : Pseudo Code]{Churn Benchmark : Pseudo Code}
291\label{fig:churn:code}
292\end{figure}
293
294\subsection{Results}
295\begin{figure}
296        \subfloat[][Throughput, 100 \ats per \proc]{
297                \resizebox{0.5\linewidth}{!}{
298                        \input{result.churn.jax.ops.pstex_t}
299                }
300                \label{fig:churn:jax:ops}
301        }
302        \subfloat[][Throughput, 1 \ats per \proc]{
303                \resizebox{0.5\linewidth}{!}{
304                        \input{result.churn.low.jax.ops.pstex_t}
305                }
306                \label{fig:churn:jax:low:ops}
307        }
308
309        \subfloat[][Latency, 100 \ats per \proc]{
310                \resizebox{0.5\linewidth}{!}{
311                        \input{result.churn.jax.ns.pstex_t}
312                }
313                \label{fig:churn:jax:ns}
314        }
315        \subfloat[][Latency, 1 \ats per \proc]{
316                \resizebox{0.5\linewidth}{!}{
317                        \input{result.churn.low.jax.ns.pstex_t}
318                }
319                \label{fig:churn:jax:low:ns}
320        }
321        \caption[Churn Benchmark on Intel]{\centering Churn Benchmark on Intel\smallskip\newline Throughput and latency of the Churn on the benchmark on the Intel machine. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
322        \label{fig:churn:jax}
323\end{figure}
324
325\begin{figure}
326        \subfloat[][Throughput, 100 \ats per \proc]{
327                \resizebox{0.5\linewidth}{!}{
328                        \input{result.churn.nasus.ops.pstex_t}
329                }
330                \label{fig:churn:nasus:ops}
331        }
332        \subfloat[][Throughput, 1 \ats per \proc]{
333                \resizebox{0.5\linewidth}{!}{
334                        \input{result.churn.low.nasus.ops.pstex_t}
335                }
336                \label{fig:churn:nasus:low:ops}
337        }
338
339        \subfloat[][Latency, 100 \ats per \proc]{
340                \resizebox{0.5\linewidth}{!}{
341                        \input{result.churn.nasus.ns.pstex_t}
342                }
343                \label{fig:churn:nasus:ns}
344        }
345        \subfloat[][Latency, 1 \ats per \proc]{
346                \resizebox{0.5\linewidth}{!}{
347                        \input{result.churn.low.nasus.ns.pstex_t}
348                }
349                \label{fig:churn:nasus:low:ns}
350        }
351        \caption[Churn Benchmark on AMD]{\centering Churn Benchmark on AMD\smallskip\newline Throughput and latency of the Churn on the benchmark on the AMD machine.
352        For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
353        \label{fig:churn:nasus}
354\end{figure}
355Figure~\ref{fig:churn:jax} shows the throughput as a function of \proc count on Intel.
356Like for the cycle benchmark, here are runtimes achieve fairly similar performance.
357Scalability is notably worst than the previous benchmarks since there is inherently more communication between processors.
358Indeed, once the number of \glspl{hthrd} goes beyond a single socket, performance ceases to improve.
359An interesting aspect to note here is that the runtimes differ in how they handle this situation.
360Indeed, when a \proc unparks a \at that was last run on a different \proc, the \at could be appended to the ready-queue local \proc or to the ready-queue of the remote \proc, which previously ran the \at.
361\CFA, tokio and Go all use the approach of unparking to the local \proc while Libfibre unparks to the remote \proc.
362In this particular benchmark, the inherent chaos of the benchmark in addition to small memory footprint means neither approach wins over the other.
363
364Figure~\ref{fig:churn:nasus} shows effectively the same picture.
365Performance improves as long as all \procs fit on a single socket.
366Beyond that performance plateaus.
367
368Again this performance demonstrate \CFA achieves satisfactory performance.
369
370\section{Locality}
371\begin{figure}
372\begin{cfa}
373Thread.main() {
374        count := 0
375        for {
376                r := random() % len(spots)
377                // go through the array
378                @work( a )@
379                spots[r].V()
380                spots[r].P()
381                count ++
382                if must_stop() { break }
383        }
384        global.count += count
385}
386\end{cfa}
387\begin{cfa}
388Thread.main() {
389        count := 0
390        for {
391                r := random() % len(spots)
392                // go through the array
393                @work( a )@
394                // pass array to next thread
395                spots[r].V( @a@ )
396                @a = @spots[r].P()
397                count ++
398                if must_stop() { break }
399        }
400        global.count += count
401}
402\end{cfa}
403\caption[Locality Benchmark : Pseudo Code]{Locality Benchmark : Pseudo Code}
404\label{fig:locality:code}
405\end{figure}
406As mentionned in the churn benchmark, when unparking a \at, it is possible to either unpark to the local or remote ready-queue.
407\footnote{It is also possible to unpark to a third unrelated ready-queue, but unless the scheduler has additional knowledge about the situation, it is unlikely to result in good cache locality.}
408The locality experiment includes two variations of the churn benchmark, where an array of data is added.
409In both variations, before @V@ing the semaphore, each \at increment random cells inside the array.
410The @share@ variation then passes the array to the shadow-queue of the semaphore, effectively transferring ownership of the array to the woken thread.
411In the @noshare@ variation the array is not passed on and each thread continously accesses its private array.
412
413The objective here is to highlight the different decision made by the runtime when unparking.
414Since each thread unparks a random semaphore, it means that it is unlikely that a \at will be unparked from the last \proc it ran on.
415In the @share@ version, this means that unparking the \at on the local \proc is appropriate since the data was last modified on that \proc.
416In the @noshare@ version, the reverse is true.
417
418The expectation for this benchmark is to see a performance inversion, where runtimes will fare notably better in the variation which matches their unparking policy.
419This should lead to \CFA, Go and Tokio achieving better performance in @share@ while libfibre achieves better performance in @noshare@.
420
421\subsection{Results}
422\begin{figure}
423        \subfloat[][Throughput share]{
424                \resizebox{0.5\linewidth}{!}{
425                        \input{result.locality.share.jax.ops.pstex_t}
426                }
427                \label{fig:locality:jax:share:ops}
428        }
429        \subfloat[][Throughput noshare]{
430                \resizebox{0.5\linewidth}{!}{
431                        \input{result.locality.noshare.jax.ops.pstex_t}
432                }
433                \label{fig:locality:jax:noshare:ops}
434        }
435
436        \subfloat[][Scalability share]{
437                \resizebox{0.5\linewidth}{!}{
438                        \input{result.locality.share.jax.ns.pstex_t}
439                }
440                \label{fig:locality:jax:share:ns}
441        }
442        \subfloat[][Scalability noshare]{
443                \resizebox{0.5\linewidth}{!}{
444                        \input{result.locality.noshare.jax.ns.pstex_t}
445                }
446                \label{fig:locality:jax:noshare:ns}
447        }
448        \caption[Locality Benchmark on Intel]{Locality Benchmark on Intel\smallskip\newline Throughput and Scalability as a function of \proc count. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
449        \label{fig:locality:jax}
450\end{figure}
451\begin{figure}
452        \subfloat[][Throughput share]{
453                \resizebox{0.5\linewidth}{!}{
454                        \input{result.locality.share.nasus.ops.pstex_t}
455                }
456                \label{fig:locality:nasus:share:ops}
457        }
458        \subfloat[][Throughput noshare]{
459                \resizebox{0.5\linewidth}{!}{
460                        \input{result.locality.noshare.nasus.ops.pstex_t}
461                }
462                \label{fig:locality:nasus:noshare:ops}
463        }
464
465        \subfloat[][Scalability share]{
466                \resizebox{0.5\linewidth}{!}{
467                        \input{result.locality.share.nasus.ns.pstex_t}
468                }
469                \label{fig:locality:nasus:share:ns}
470        }
471        \subfloat[][Scalability noshare]{
472                \resizebox{0.5\linewidth}{!}{
473                        \input{result.locality.noshare.nasus.ns.pstex_t}
474                }
475                \label{fig:locality:nasus:noshare:ns}
476        }
477        \caption[Locality Benchmark on AMD]{Locality Benchmark on AMD\smallskip\newline Throughput and Scalability as a function of \proc count. For Throughput higher is better, for Scalability lower is better. Each series represent 15 independent runs, the dotted lines are extremums while the solid line is the medium.}
478        \label{fig:locality:nasus}
479\end{figure}
480
481Figure~\ref{fig:locality:jax} shows that the results somewhat follow the expectation.
482On the left of the figure showing the results for the shared variation, where \CFA and tokio outperform libfibre as expected.
483And correspondingly on the right, we see the expected performance inversion where libfibre now outperforms \CFA and tokio.
484Otherwise the results are similar to the churn benchmark, with lower throughtput due to the array processing.
485It is unclear why Go's performance is notably worst than the other runtimes.
486
487Figure~\ref{fig:locality:nasus} shows the same experiment on AMD.
488\todo{why is cfa slower?}
489Again, we see the same story, where tokio and libfibre swap places and Go trails behind.
490
491\section{Transfer}
492The last benchmark is more of an experiment than a benchmark.
493It tests the behaviour of the schedulers for a misbehaved workload.
494In this workload, one of the \at is selected at random to be the leader.
495The leader then spins in a tight loop until it has observed that all other \ats have acknowledged its leadership.
496The leader \at then picks a new \at to be the next leader and the cycle repeats.
497The benchmark comes in two flavours for the non-leader \ats:
498once they acknowledged the leader, they either block on a semaphore or spin yielding.
499
500The experiment is designed to evaluate the short-term load-balancing of a scheduler.
501Indeed, schedulers where the runnable \ats are partitioned on the \procs may need to balance the \ats for this experiment to terminate.
502This problem occurs because the spinning \at is effectively preventing the \proc from running any other \at.
503In the semaphore flavour, the number of runnable \ats eventually dwindles down to only the leader.
504This scenario is a simpler case to handle for schedulers since \procs eventually run out of work.
505In the yielding flavour, the number of runnable \ats stays constant.
506This scenario is a harder case to handle because corrective measures must be taken even when work is available.
507Note, runtime systems with preemption circumvent this problem by forcing the spinner to yield.
508
509I both flavours, the experiment effectively measures how long it takes for all \ats to run once after a given synchronization point.
510In 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:
511$ \frac{CSL + SL}{NP - 1}$, where $CSL$ is the context switch latency, $SL$ is the cost for enqueuing and dequeuing a \at and $NP$ is the number of \procs.
512However, if the scheduler allows \ats to run many times before other \ats are able to run once, this delay will increase.
513The semaphore version is an approximation of the strictly FIFO scheduling, where none of the \ats \emph{attempt} to run more than once.
514The benchmark effectively provides the fairness guarantee in this case.
515In the yielding version however, the benchmark provides no such guarantee, which means the scheduler has full responsability and any unfairness will be measurable.
516
517While this is a fairly artificial scenario, it requires only a few simple pieces.
518The yielding version of this simply creates a scenario where a \at runs uninterrupted in a saturated system, and starvation has a easily measured impact.
519However, \emph{any} \at that runs uninterrupted for a significant period of time in a saturated system could lead to this kind of starvation.
520
521\begin{figure}
522\begin{cfa}
523Thread.lead() {
524        this.idx_seen = ++lead_idx
525        if lead_idx > stop_idx {
526                done := true
527                return
528        }
529        // Wait for everyone to acknowledge my leadership
530        start: = timeNow()
531        for t in threads {
532                while t.idx_seen != lead_idx {
533                        asm pause
534                        if (timeNow() - start) > 5 seconds { error() }
535                }
536        }
537        // pick next leader
538        leader := threads[ prng() % len(threads) ]
539        // wake every one
540        if ! exhaust {
541                for t in threads {
542                        if t != me { t.wake() }
543                }
544        }
545}
546Thread.wait() {
547        this.idx_seen := lead_idx
548        if exhaust { wait() }
549        else { yield() }
550}
551Thread.main() {
552        while !done  {
553                if leader == me { this.lead() }
554                else { this.wait() }
555        }
556}
557\end{cfa}
558\caption[Transfer Benchmark : Pseudo Code]{Transfer Benchmark : Pseudo Code}
559\label{fig:transfer:code}
560\end{figure}
561
562\subsection{Results}
563\begin{figure}
564\begin{centering}
565\begin{tabular}{r | c c c c | c c c c }
566Machine   &                     \multicolumn{4}{c |}{Intel}                &          \multicolumn{4}{c}{AMD}                    \\
567Variation & \multicolumn{2}{c}{Park} & \multicolumn{2}{c |}{Yield} & \multicolumn{2}{c}{Park} & \multicolumn{2}{c}{Yield} \\
568\procs    &      2      &      192   &      2      &      192      &      2      &      256   &      2      &      256    \\
569\hline
570\CFA      & 106 $\mu$& j200       & 68.4 $\mu$s & ~1.2 ms       & 174 $\mu$& ~28.4 ms   & 78.8~~$\mu$s& ~~1.21 ms   \\
571libfibre  & 127 $\mu$&            & DNC         & DNC           & 156 $\mu$& ~36.7 ms   & DNC         & DNC         \\
572Go        & 106 $\mu$& j200       & 24.6 ms     & 74.3 ms       & 271 $\mu$& 121.6 ms   & ~~1.21~ms   & 117.4 ms    \\
573tokio     & 289 $\mu$&            & DNC         & DNC           & 157 $\mu$& 111.0 ms   & DNC         & DNC
574\end{tabular}
575\end{centering}
576\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. DNC 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. }
577\label{fig:transfer:res}
578\end{figure}
579Figure~\ref{fig:transfer:res} shows the result for the transfer benchmark with 2 \procs and all \procs, where each experiement runs 100 \at per \proc.
580Note 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.
581As such, data points that are the on the same order of magnitude as eachother should be basically considered equal.
582The takeaway of this experiement is the presence of very large differences.
583The semaphore variation is denoted ``Park'', where the number of \ats dwindles down as the new leader is acknowledged.
584The yielding variation is denoted ``Yield''.
585The experiement was only run for the extremums of the number of cores since the scaling per core behaves like previous experiements.
586This experiments clearly demonstrate that while the other runtimes achieve similar performance, \CFA achieves significantly better fairness.
587The semaphore variation serves as a control group, where all runtimes are expected to transfer leadership fairly quickly.
588Since \ats block after acknowledging the leader, this experiment effectively measures how quickly \procs can steal \ats from the \proc running leader.
589Figure~\ref{fig:transfer:res} shows that while Go and Tokio are slower, all runtime achieve decent latency.
590However, the yielding variation shows an entirely different picture.
591Since libfibre and tokio have a traditional work-stealing scheduler, \procs that have \ats on their local queues will never steal from other \procs.
592The result is that the experiement simply does not complete for these runtime.
593Without \procs stealing from the \proc running the leader, the experiment will simply never terminate.
594Go manages to complete the experiement because it adds preemption on top of classic work-stealing.
595However, since preemption is fairly costly it achieves significantly worst performance.
596In contrast, \CFA achieves equivalent performance in both variations, demonstrating very good fairness.
597Interestingly \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.
Note: See TracBrowser for help on using the repository browser.