# Changeset e378c73

Ignore:
Timestamp:
Aug 13, 2022, 4:54:32 PM (7 weeks ago)
Branches:
Children:
2ae6a99
Parents:
111d993
Message:

Fleshed out some more the evaluation sections, still waiting on some new data for churn nasus, locality nasus and memcached update

Location:
doc/theses/thierry_delisle_PhD/thesis/text
Files:
2 edited

### Legend:

Unmodified
 r111d993 This chapter presents five different experimental setup, evaluating some of the basic features of \CFA's scheduler. \section{Benchmark Environment} \section{Benchmark Environment}\label{microenv} All benchmarks are run on two distinct hardware platforms. \begin{description} The most basic evaluation of any ready queue is to evaluate the latency needed to push and pop one element from the ready queue. Since these two operation also describe a @yield@ operation, many systems use this operation as the most basic benchmark. However, yielding can be treated as a special case by optimizing it away since the number of ready \ats does not change. Not all systems perform this optimization, but those that do have an artificial performance benefit because the yield becomes a \emph{nop}. However, yielding can be treated as a special case and some aspects of the scheduler can be optimized away since the number of ready \ats does not change. Not all systems perform this type of optimization, but those that do have an artificial performance benefit because the yield becomes a \emph{nop}. For this reason, I chose a different first benchmark, called \newterm{Cycle Benchmark}. This 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. Hence, the underlying runtime cannot rely on the number of ready \ats staying constant over the duration of the experiment. In 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. In fact, the total number of \ats waiting on the ready queue is expected to vary because of the delay between the next \at unparking and the current \at parking. That is, the runtime cannot anticipate that the current task will immediately park. As 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. Every runtime system must handle this race and cannot optimized away the ready-queue pushes and pops. As well, the size of the cycle is also decided based on this delay. Note that, an unpark is like a V on a semaphore, so the subsequent park (P) may not block. If this happens, the scheduler push and pop are avoided and the results of the experiment would be skewed. Because of time-slicing or because cycles can be spread over multiple \procs, a small cycle may see the chain of unparks go full circle before the first \at parks. Every runtime system must handle this race and but cannot optimized away the ready-queue pushes and pops if the cycle is long enough. To 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. (Note, an unpark is like a V on a semaphore, so the subsequent park (P) may not block.) Finally, to further mitigate any underlying push/pop optimizations, especially on SMP machines, multiple rings are created in the experiment. The 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. The experiment was run 15 times for each series and processor count and the \emph{$\times$}s on the graph show all of the results obtained. Each series also has a solid and two dashed lines highlighting the median, maximum and minimum result respectively. This presentation offers an overview of the distribution of the results for each series. The experimental setup uses taskset to limit the placement of \glspl{kthrd} by the operating system. As mentioned in Section~\ref{microenv}, the experiement is setup to prioritize running on 2 \glspl{hthrd} per core before running on multiple sockets. For 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 but \emph{with} hyperthreading. This pattern is repeated between 49 and 96, between 97 and 144, and between 145 and 192. On AMD, the same algorithm is used, but the machine only has 2 sockets. So hyperthreading\footnote{Hyperthreading normally refers specifically to the technique used by Intel, however here it is loosely used to refer to AMD's equivalent feature.} is used when the \proc count reach 65 and 193. Figure~\ref{fig:cycle:jax:ops} and Figure~\ref{fig:cycle:jax:ns} show that for 100 cycles per \proc, \CFA, Go and Tokio all obtain effectively the same performance. Libfibre is slightly behind in this case but still scales decently. As a result of the \gls{kthrd} placement, we can see that additional \procs from 25 to 48 offer less performance improvements for all runtimes. As expected, this pattern repeats between \proc count 72 and 96. The performance goal of \CFA is to obtain equivalent performance to other, less fair schedulers and that is what results show. Figure~\ref{fig:cycle:jax:ops} and \ref{fig:cycle:jax:ns} show very good throughput and scalability for all runtimes. The experimental setup prioritizes running on 2 \glspl{hthrd} per core before running on multiple sockets. The effect of that setup is seen from 25 to 48 \procs, running on 24 core with 2 \glspl{hthrd} per core. This effect is again repeated from 73 and 96 \procs, where it happens on the second CPU. When running only a single cycle, most runtime achieve lower throughput because of the idle-sleep mechanism. Figure~\ref{fig:cycle:nasus} show effectively the same story happening on AMD as it does on Intel. The different performance bumps due to cache topology happen at different locations and there is a little more variability. However, in all cases \CFA is still competitive with other runtimes. When running only a single cycle, the story is slightly different. \CFA and tokio obtain very smiliar results overall, but tokio shows notably more variations in the results. While \CFA, Go and tokio achive equivalent performance with 100 cycles per \proc, with only 1 cycle per \proc Go achieves slightly better performance. This difference in throughput and scalability is due to the idle-sleep mechanism. With very few cycles, stealing or helping can cause a cascade of tasks migration and trick \proc into very short idle sleeps. Both effect will negatively affect performance. An interesting and unusual result is that libfibre achieves better performance with fewer cycle. This suggest that the cascade effect is never present in libfibre and that some bottleneck disappears in this context. However, I did not investigate this result any deeper. Figure~\ref{fig:cycle:nasus} show a similar story happening on AMD as it does on Intel. The different performance improvements and plateaus due to cache topology appear at the expected \proc counts of 64, 128 and 192, for the same reasons as on Intel. Unlike Intel, on AMD all 4 runtimes achieve very similar throughput and scalability for 100 cycles per \proc. In the 1 cycle per \proc experiment, the same performance increase for libfibre is visible. However, unlike on Intel, tokio achieves the same performance as Go rather than \CFA. This leaves \CFA trailing behind in this particular case, but only at hight core counts. Presumably this is because in this case, \emph{any} helping is likely to cause a cascade of \procs running out of work and attempting to steal. Since this effect is only problematic in cases with 1 \at per \proc it is not very meaningful for the general performance. The conclusion from both architectures is that all of the compared runtime have fairly equivalent performance in this scenario. Which demonstrate that in this case \CFA achieves equivalent performance. \section{Yield} It is fairly obvious why I claim this benchmark is more artificial. The throughput is dominated by the mechanism used to handle the @yield@. \CFA does not have special handling for @yield@ and achieves very similar performance to the cycle benchmark. Libfibre 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. Go puts yielding goroutines on a secondary global ready-queue, giving them lower priority. The result is that multiple \glspl{hthrd} contend for the global queue and performance suffers drastically. Based on the scalability, Tokio obtains the same poor performance and therefore it is likely it handles @yield@ in a similar fashion. \CFA does not have special handling for @yield@ but the experiment requires less synchronization. As a result achieves better performance than the cycle benchmark, but still comparable. When the number of \ats is reduce to 1 per \proc, the cost of idle sleep also comes into play in a very significant way. If 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. If anything causes a \at migration, where two \ats end-up on the same ready-queue, work-stealing will start occuring and could cause several \ats to shuffle around. In the process, several \procs can go to sleep transiently if they fail to find where the \ats were shuffled to. In \CFA, spurious bursts of latency can trick a \proc into helping, triggering this effect. However, 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. However, since user-level threading with equal number of \ats and \procs is a somewhat degenerate case, especially when context-switching very often, this result is not particularly meaningful and is only included for completness. Libfibre 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. Additionally, when only running 1 \at per \proc, libfibre optimizes further and forgoes the context-switch entirely. This results in incredible performance results comparing to the other runtimes. In stark contrast with libfibre, Go puts yielding goroutines on a secondary global ready-queue, giving them lower priority. The result is that multiple \glspl{hthrd} contend for the global queue and performance suffers drastically. Based on the scalability, Tokio obtains the similarly poor performance and therefore it is likely it handles @yield@ in a similar fashion. However, it must be doing something different since it does scale at low \proc count. Again, Figure~\ref{fig:yield:nasus} show effectively the same story happening on AMD as it does on Intel. In these benchmarks, \ats can be easily partitioned over the different \procs upfront and none of the \ats communicate with each other. The 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. With 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. This dequeuing results in either contention on the remote queue and/or \glspl{rmr} on \at data structure. The Churn benchmark represents more chaotic executions, where there is more communication among \ats but no apparent relation between the last \proc on which a \at ran and blocked, and the \proc that subsequently unblocks it. With 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 place it on a remote queue. This enqueuing results in either contention on the remote queue and/or \glspl{rmr} on the \at data structure. In 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. \label{fig:churn:jax:ops} } \subfloat[][Throughput, 1 \ats per \proc]{ \subfloat[][Throughput, 2 \ats per \proc]{ \resizebox{0.5\linewidth}{!}{ \input{result.churn.low.jax.ops.pstex_t} \label{fig:churn:jax:ns} } \subfloat[][Latency, 1 \ats per \proc]{ \subfloat[][Latency, 2 \ats per \proc]{ \resizebox{0.5\linewidth}{!}{ \input{result.churn.low.jax.ns.pstex_t} \label{fig:churn:nasus:ops} } \subfloat[][Throughput, 1 \ats per \proc]{ \subfloat[][Throughput, 2 \ats per \proc]{ \resizebox{0.5\linewidth}{!}{ \input{result.churn.low.nasus.ops.pstex_t} \label{fig:churn:nasus:ns} } \subfloat[][Latency, 1 \ats per \proc]{ \subfloat[][Latency, 2 \ats per \proc]{ \resizebox{0.5\linewidth}{!}{ \input{result.churn.low.nasus.ns.pstex_t} \label{fig:churn:nasus} \end{figure} Figure~\ref{fig:churn:jax} shows the throughput as a function of \proc count on Intel. Like for the cycle benchmark, here are runtimes achieve fairly similar performance. Figure~\ref{fig:churn:jax} and Figure~\ref{fig:churn:nasus} show the throughput as a function of \proc count on Intel and AMD respectively. It uses the same representation as the previous benchmark : 15 runs where the dashed line show the extremums and the solid line the median. The performance cost of crossing the cache boundaries is still visible at the same \proc count. However, this benchmark has performance dominated by the cache traffic as \proc are constantly accessing the eachother's data. Scalability is notably worst than the previous benchmarks since there is inherently more communication between processors. Indeed, once the number of \glspl{hthrd} goes beyond a single socket, performance ceases to improve. In this particular benchmark, the inherent chaos of the benchmark in addition to small memory footprint means neither approach wins over the other. Figure~\ref{fig:churn:nasus} shows effectively the same picture. Like for the cycle benchmark, here all runtimes achieve fairly similar performance. Performance improves as long as all \procs fit on a single socket. Beyond that performance plateaus. Again this performance demonstrate \CFA achieves satisfactory performance. Beyond that performance starts to suffer from increased caching costs. Indeed on Figures~\ref{fig:churn:jax:ops} and \ref{fig:churn:jax:ns} show that with 100 \ats per \proc, \CFA, libfibre, and tokio achieve effectively equivalent performance for most \proc count. Interestingly, Go starts with better scaling at very low \proc counts but then performance quickly plateaus, resulting in worse performance at higher \proc counts. This performance difference disappears in Figures~\ref{fig:churn:jax:low:ops} and \ref{fig:churn:jax:low:ns}, where the performance of all runtimes is equivalent. Figure~\ref{fig:churn:nasus} again shows a similar story. \CFA, libfibre, and tokio achieve effectively equivalent performance for most \proc count. Go still shows different scaling than the other 3 runtimes. The distinction is that on AMD the difference between Go and the other runtime is more significant. Indeed, even with only 1 \at per \proc, Go achieves notably different scaling than the other runtimes. One possible explanation for this difference is that since Go has very few available concurrent primitives, a channel was used instead of a semaphore. On paper a semaphore can be replaced by a channel and with zero-sized objects passed along equivalent performance could be expected. However, in practice there can be implementation difference between the two. This is especially true if the semaphore count can get somewhat high. Note that this replacement is also made in the cycle benchmark, however in that context it did not seem to have a notable impact. The objective of this benchmark is to demonstrate that unparking \ats from remote \procs do not cause too much contention on the local queues. Indeed, the fact all runtimes achieve some scaling at lower \proc count demontrate that migrations do not need to be serialized. Again these result demonstrate \CFA achieves satisfactory performance. \section{Locality} \end{figure} As mentionned in the churn benchmark, when unparking a \at, it is possible to either unpark to the local or remote ready-queue. \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.} \footnote{It is also possible to unpark to a third unrelated ready-queue, but without additional knowledge about the situation, there is little to suggest this would not degrade performance.} The locality experiment includes two variations of the churn benchmark, where an array of data is added. In both variations, before @V@ing the semaphore, each \at increment random cells inside the array. The @share@ variation then passes the array to the shadow-queue of the semaphore, effectively transferring ownership of the array to the woken thread. The @share@ variation then passes the array to the shadow-queue of the semaphore, transferring ownership of the array to the woken thread. In the @noshare@ variation the array is not passed on and each thread continously accesses its private array. Since 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. In the @share@ version, this means that unparking the \at on the local \proc is appropriate since the data was last modified on that \proc. In the @noshare@ version, the reverse is true. In the @noshare@ version, the unparking the \at on the remote \proc is the appropriate approach. The expectation for this benchmark is to see a performance inversion, where runtimes will fare notably better in the variation which matches their unparking policy. This should lead to \CFA, Go and Tokio achieving better performance in @share@ while libfibre achieves better performance in @noshare@. Indeed, \CFA, Go and Tokio have the default policy of unpark \ats on the local \proc, where as libfibre has the default policy of unparks \ats wherever they last ran. \subsection{Results} \end{figure} Figure~\ref{fig:locality:jax} shows that the results somewhat follow the expectation. Figure~\ref{fig:locality:jax} and \ref{fig:locality:nasus} shows the results on Intel and AMD respectively. In 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@. that the results somewhat follow the expectation. On the left of the figure showing the results for the shared variation, where \CFA and tokio outperform libfibre as expected. And correspondingly on the right, we see the expected performance inversion where libfibre now outperforms \CFA and tokio. Note, runtime systems with preemption circumvent this problem by forcing the spinner to yield. I both flavours, the experiment effectively measures how long it takes for all \ats to run once after a given synchronization point. In both flavours, the experiment effectively measures how long it takes for all \ats to run once after a given synchronization point. In 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: $\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. While this is a fairly artificial scenario, it requires only a few simple pieces. The yielding version of this simply creates a scenario where a \at runs uninterrupted in a saturated system, and starvation has a easily measured impact. The yielding version of this simply creates a scenario where a \at runs uninterrupted in a saturated system, and starvation has an easily measured impact. However, \emph{any} \at that runs uninterrupted for a significant period of time in a saturated system could lead to this kind of starvation. \procs    &      2      &      192   &      2      &      192      &      2      &      256   &      2      &      256    \\ \hline \CFA      & 106 $\mu$s  & j200       & 68.4 $\mu$s & ~1.2 ms       & 174 $\mu$s  & ~28.4 ms   & 78.8~~$\mu$s& ~~1.21 ms   \\ libfibre  & 127 $\mu$s  &            & DNC         & DNC           & 156 $\mu$s  & ~36.7 ms   & DNC         & DNC         \\ Go        & 106 $\mu$s  & j200       & 24.6 ms     & 74.3 ms       & 271 $\mu$s  & 121.6 ms   & ~~1.21~ms   & 117.4 ms    \\ tokio     & 289 $\mu$s  &            & DNC         & DNC           & 157 $\mu$s  & 111.0 ms   & DNC         & DNC \CFA      & 106 $\mu$s  & ~19.9 ms   & 68.4 $\mu$s & ~1.2 ms       & 174 $\mu$s  & ~28.4 ms   & 78.8~~$\mu$s& ~~1.21 ms   \\ libfibre  & 127 $\mu$s  & ~33.5 ms   & DNC         & DNC           & 156 $\mu$s  & ~36.7 ms   & DNC         & DNC         \\ Go        & 106 $\mu$s  & ~64.0 ms   & 24.6 ms     & 74.3 ms       & 271 $\mu$s  & 121.6 ms   & ~~1.21~ms   & 117.4 ms    \\ tokio     & 289 $\mu$s  & 180.6 ms   & DNC         & DNC           & 157 $\mu$s  & 111.0 ms   & DNC         & DNC \end{tabular} \end{centering} The yielding variation is denoted Yield''. The experiement was only run for the extremums of the number of cores since the scaling per core behaves like previous experiements. This experiments clearly demonstrate that while the other runtimes achieve similar performance, \CFA achieves significantly better fairness. This experiments clearly demonstrate that while the other runtimes achieve similar performance in previous benchmarks, here \CFA achieves significantly better fairness. The semaphore variation serves as a control group, where all runtimes are expected to transfer leadership fairly quickly. Since \ats block after acknowledging the leader, this experiment effectively measures how quickly \procs can steal \ats from the \proc running leader. However, since preemption is fairly costly it achieves significantly worst performance. In contrast, \CFA achieves equivalent performance in both variations, demonstrating very good fairness. Interestingly \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. Interestingly \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.