source: doc/theses/thierry_delisle_PhD/thesis/text/conclusion.tex @ 0fec6c1

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

proofread conclusion chapter

  • Property mode set to 100644
File size: 9.9 KB
Line 
1\chapter{Conclusion}\label{conclusion}
2
3Building the \CFA runtime has been a challenging project.
4The work was divided between high-level concurrency design and a user-level threading runtime (Masters thesis), and low-level support of the user-level runtime using OS kernel-threading and its (multiple) I/O subsystems (Ph.D. thesis).
5Because I am the main developer for both components of this project, there is strong continuity across the design and implementation.
6This continuity provides a consistent approach to advanced control-flow and concurrency, with easier development, management and maintenance of the runtime in the future.
7I believed my Masters work would provide the background to make the Ph.D work reasonably straightforward.
8However, I discovered two significant challenges.
9
10First, modern symmetric multiprocessing CPU have significant performance penalties for communication (often cache related).
11A SQMS scheduler (see Section~\ref{sched}), with its \proc-shared ready-queue, has perfect load-balancing but poor affinity resulting in high communication across \procs.
12A MQMS scheduler, with its \proc-specific ready-queues, has poor load-balancing but perfect affinity often resulting in significantly reduced communication.
13However, implementing fairness for an MQMS scheduler is difficult, since fairness requires \procs to be aware of each other's ready-queue progress, \ie communicated knowledge.
14% This challenge is made harder when comparing against MQMS schedulers (see Section\ref{sched}) which have very little inter-\proc communication.
15For balanced workloads with little or no data sharing (embarrassingly parallel), an MQMS scheduler is near optimal, \eg state-of-the-art work-stealing schedulers.
16For these kinds of fair workloads, adding fairness must be low-cost to hide the communication costs needed for global ready-queue progress or performance suffers.
17
18Second, the kernel locking, threading, and I/O in the Linux operating system offers very little flexibility, and are not designed to facilitate user-level threading.
19There are multiple concurrency aspects in Linux that require carefully following a strict procedure in order to achieve acceptable performance.
20To be fair, many of these concurrency aspects were designed 30-40 years ago, when there were few multi-processor computers and concurrency knowledge was just developing.
21It is unfortunate that little has changed in the intervening years.
22
23Also, my decision to use @io_uring@ was both a positive and negative.
24The positive is that @io_uring@ supports the panoply of I/O mechanisms in Linux;
25hence, the \CFA runtime uses one I/O mechanism to provide non-blocking I/O, rather than using @select@ to handle TTY I/O, @epoll@ to handle network I/O, and managing a thread pool to handle disk I/O.
26Merging all these different I/O mechanisms into a coherent scheduling implementation would require much more work than what is present in this thesis, as well as a detailed knowledge of multiple I/O mechanisms.
27The negative is that @io_uring@ is new and developing.
28As a result, there is limited documentation, few places to find usage examples, and multiple errors that required workarounds.
29
30Given what I now know about @io_uring@, I would say it is insufficiently coupled with the Linux kernel to properly handle non-blocking I/O.
31It does not seem to reach deep into the kernel's handling of \io, and as such it must contend with the same realities that users of @epoll@ must contend with.
32Specifically, in cases where @O_NONBLOCK@ behaves as desired, operations must still be retried.
33To preserve the illusion of asynchronicity requires delegating these operations to kernel threads.
34This requirement is also true of cases where @O_NONBLOCK@ does not prevent blocking.
35Spinning up internal kernel threads to handle blocking scenarios is what developers already do outside of the kernel, and managing these threads adds significant burden to the system.
36Nonblocking I/O should not be handled in this way.
37
38\section{Goals}
39This work focusses on efficient and fair scheduling of the multiple CPUs, which are ubiquitous on all modern computers.
40The levels of indirection to the CPUs are:
41\begin{itemize}
42\item
43The \CFA presentation of concurrency through multiple high-level language constructs.
44\item
45The OS presentation of concurrency through multiple kernel threads within an application.
46\item
47The OS and library presentation of disk and network I/O, and many secondary library routines that directly and indirectly use these mechanisms.
48\end{itemize}
49The key aspect of all of these mechanisms is that control flow can block, which immediately hinders any level above from making scheduling decision as a result.
50Fundamentally, scheduling needs to understand all the mechanisms used by threads that affect their state changes.
51
52The underlying goal of this thesis is scheduling the complex hardware components that make up a computer to provide good utilization and fairness.
53However, direct hardware scheduling is only possible in the OS.
54Instead, this thesis is performing arms-length application scheduling of the hardware components through a set of OS interfaces that indirectly manipulate the hardware components.
55This can quickly lead to tensions when the OS interface has different use cases in mind.
56
57As \CFA aims to increase productivity and safety of C, while maintaining its performance, this places a huge burden on the \CFA runtime to achieve these goals.
58Productivity and safety manifest in removing scheduling pitfalls in the efficient usage of the threading runtime.
59Performance manifests in making efficient use of the underlying kernel threads that provide indirect access to the CPUs.
60
61This thesis achieves its stated contributes by presenting:
62\begin{enumerate}[leftmargin=*]
63\item
64A scalable low-latency scheduler that offers improved starvation prevention (progress guarantee) compared to other state-of-the-art schedulers, including NUMA awareness.
65\item
66The scheduler demonstrates a core algorithm that provides increased fairness through helping, as well as optimizations which virtually remove the cost of this fairness.
67\item
68An implementation of user-level \io blocking is incorporated into the scheduler, which achieves the same performance and fairness balance as the scheduler itself.
69\item
70These core algorithms are further extended with a low-latency idle-sleep mechanism, which allows the \CFA runtime to stay viable for workloads that do not consistently saturate the system.
71\end{enumerate}
72Finally, the complete scheduler is fairly simple with low-cost execution, meaning the total cost of scheduling during thread state-changes is low.
73
74\section{Future Work}
75While the \CFA runtime achieves a better compromise, in term of performance and fairness, than other schedulers, I believe further improvements can be made to reduce or eliminate the few cases where performance does deteriorate.
76Fundamentally, achieving performance and starvation freedom will always be goals with opposing needs even outside of scheduling algorithms.
77
78\subsection{Idle Sleep}
79A difficult challenge, not fully address in this thesis, is idle-sleep.
80While a correct and somewhat low-cost idle-sleep mechanism is presented, several of the benchmarks show notable performance degradation when too few \ats are present in the system.
81The idle sleep mechanism could therefore benefit from a reduction of spurious cases of sleeping.
82Furthermore, this thesis did not present any heuristic for when \procs should be put to sleep and when \procs should be woken up.
83While relaxed timestamps and topology awareness made a notable improvements in performance, neither of these techniques are used for the idle-sleep mechanism.
84
85Here are opportunities where these techniques could be use:
86\begin{itemize}
87\item
88The mechanism uses a hand-shake between notification and sleep to ensure that no \at is missed.
89\item
90The hand-shake correctness is critical when the last \proc goes to sleep but could be relaxed when several \procs are awake.
91\item
92Furthermore, organizing the sleeping \procs as a LIFO stack makes sense to keep cold \procs as cold as possible, but it might be more appropriate to attempt to keep cold CPU sockets instead.
93\end{itemize}
94However, using these techniques would require significant investigation.
95For example, keeping a CPU socket cold might be appropriate for power consumption reasons but can affect overall memory bandwidth.
96The balance between these approaches is not obvious.
97I am aware there is a host of low-power research that could be tapped here.
98
99\subsection{Hardware}
100One challenge that needed to be overcome for this thesis is that the modern x86-64 processors has very few tools to implement fairness.
101\Glspl{proc} attempting to help each other inherently cause cache-coherence traffic.
102However, as mentioned in Section~\ref{helping}, relaxed requirements mean this traffic is not necessarily productive.
103In cases like this one, there is an opportunity to improve performance by extending the hardware.
104
105Many different extensions are suitable here.
106For example, when attempting to read remote timestamps for helping, it would be useful to allow cancelling the remote read if it leads to significant latency.
107If the latency is due to a recent cache invalidation, it is unlikely the timestamp is old and that helping is needed.
108As such, simply moving on without the result is likely to be acceptable.
109Another option is to read multiple memory addresses and only wait for \emph{one of} these reads to retire.
110This approach has a similar effect, where cache lines with more traffic are on less often.
111In both of these examples, some care is needed to ensure that reads to an address \emph{sometime} retire.
112
113Note, this idea is similar to \newterm{Hardware Transactional Memory}~\cite{HTM}, which allows groups of instructions to be aborted and rolled-back if they encounter memory conflicts when being retired.
114However, I believe this feature is generally aimed at large groups of instructions.
115A more fine-grained approach may be more amenable by carefully picking which aspects of an algorithm require exact correctness and which do not.
Note: See TracBrowser for help on using the repository browser.