Changes in / [f7e4f8e8:4ae78c1]
- Location:
- doc/theses/thierry_delisle_PhD
- Files:
-
- 2 deleted
- 12 edited
-
comp_II/presentation.tex (modified) (6 diffs)
-
comp_II/presentationstyle.sty (modified) (2 diffs)
-
thesis/Makefile (modified) (3 diffs)
-
thesis/fig/system.fig (modified) (4 diffs)
-
thesis/glossary.tex (modified) (3 diffs)
-
thesis/local.bib (deleted)
-
thesis/text/core.tex (modified) (4 diffs)
-
thesis/text/existing.tex (deleted)
-
thesis/text/front.tex (modified) (1 diff)
-
thesis/text/intro.tex (modified) (1 diff)
-
thesis/text/io.tex (modified) (2 diffs)
-
thesis/text/practice.tex (modified) (1 diff)
-
thesis/text/runtime.tex (modified) (1 diff)
-
thesis/thesis.tex (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/thierry_delisle_PhD/comp_II/presentation.tex
rf7e4f8e8 r4ae78c1 36 36 \miniframeson 37 37 } 38 \section{Concurrency and \CFA} 39 \begin{frame}{Project} 40 \begin{center} 41 {\large Produce a scheduler for \CFA that is simple for programmers to understand and offers good general performance.} 42 \end{center} 43 \end{frame} 44 %------------------------------ 38 \section{\CFA and Concurrency} 45 39 \begin{frame}{\CFA} 46 \CFA is a modern extension of C.47 It adds to C : overloading, constructors/destructors, polymorphism, and much more.48 49 ~\newline50 For this project, the relevant aspects are:51 \begin{itemize}52 \item Fast and safe system language.53 \item Threading.54 \item Manual memory management.55 \end{itemize}56 40 57 41 \end{frame} … … 120 104 \begin{frame}{Priority Scheduling} 121 105 \begin{center} 122 {\large106 {\large 123 107 Runs all ready threads in group \textit{A} before any ready threads in group \textit{B}. 124 108 } … … 152 136 153 137 Processors begin busy for long periods can mean starvation. 154 \end{frame}155 %------------------------------156 \begin{frame}{Scheduling in Practice: Summary}157 \begin{columns}158 \begin{column}{0.5\textwidth}159 \textbf{Feedback Scheduling}160 \newline161 162 \begin{itemize}163 \item Inappropriate for short lived threads.164 \item Overkill for cooperating threads.\newline165 \end{itemize}166 \end{column}167 \begin{column}{0.5\textwidth}168 \textbf{Priority Scheduling}169 \newline170 171 \begin{itemize}172 \item Allows lasting starvation.\newline173 \item Hard to reason about.\newline~\newline174 \end{itemize}175 \end{column}176 \end{columns}177 178 ~\newline179 ~\newline180 \CFA would benefit from something different.181 138 \end{frame} 182 139 %============================== … … 233 190 \begin{itemize} 234 191 \item Acquire for reading for normal scheduling operations. 235 \item Acquire for writingwhen resizing the array and creating/deleting internal queues.192 \item Acquire for right when resizing the array and creating/deleting internal queues. 236 193 \end{itemize} 237 194 \end{frame} … … 357 314 Runtime system and scheduling are still open topics. 358 315 \newline 359 \newline360 316 361 317 This work offers a novel runtime and scheduling package. 362 \newline363 318 \newline 364 319 … … 381 336 382 337 %------------------------------ 383 \begin{frame}{ }338 \begin{frame}{Timeline} 384 339 \begin{center} 385 340 {\large Questions?} -
doc/theses/thierry_delisle_PhD/comp_II/presentationstyle.sty
rf7e4f8e8 r4ae78c1 20 20 \setbeamertemplate{blocks}[rounded][shadow=false] 21 21 \newcommand\xrowht[2][0]{\addstackgap[.5\dimexpr#2\relax]{\vphantom{#1}}} 22 \setbeamertemplate{sections/subsections in toc}{\inserttocsectionnumber.~\inserttocsection}23 22 24 23 %============================== … … 37 36 \setbeamercolor{palette primary}{bg=colbg} 38 37 \setbeamercolor{palette tertiary}{fg=red} 39 \setbeamercolor{section in toc}{fg=white}40 \setbeamercolor{subsection in toc}{fg=gray}41 38 42 39 %============================== -
doc/theses/thierry_delisle_PhD/thesis/Makefile
rf7e4f8e8 r4ae78c1 15 15 front \ 16 16 intro \ 17 existing \18 17 runtime \ 19 18 core \ … … 28 27 base \ 29 28 empty \ 30 system \31 29 } 32 30 … … 39 37 ## Define the documents that need to be made. 40 38 all: thesis.pdf 41 thesis.pdf: ${TEXTS} ${FIGURES} ${PICTURES} glossary.tex local.bib39 thesis.pdf: ${TEXTS} ${FIGURES} ${PICTURES} glossary.tex 42 40 43 41 DOCUMENT = thesis.pdf -
doc/theses/thierry_delisle_PhD/thesis/fig/system.fig
rf7e4f8e8 r4ae78c1 1 #FIG 3.2 Produced by xfig version 3.2. 7b1 #FIG 3.2 Produced by xfig version 3.2.5c 2 2 Landscape 3 3 Center … … 36 36 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4500 3600 15 15 4500 3600 4515 3615 37 37 -6 38 6 3225 4125 4650 4425 39 6 4350 4200 4650 4350 40 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4425 4275 15 15 4425 4275 4440 4290 41 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4500 4275 15 15 4500 4275 4515 4290 42 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 4575 4275 15 15 4575 4275 4590 4290 43 -6 44 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3450 4275 225 150 3450 4275 3675 4425 45 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4050 4275 225 150 4050 4275 4275 4425 46 -6 47 6 6675 4125 7500 4425 48 6 7200 4200 7500 4350 49 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7275 4275 15 15 7275 4275 7290 4290 50 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7350 4275 15 15 7350 4275 7365 4290 51 1 3 0 1 -1 -1 0 0 20 0.000 1 0.0000 7425 4275 15 15 7425 4275 7440 4290 52 -6 53 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 6900 4275 225 150 6900 4275 7125 4425 54 -6 38 55 6 6675 3525 8025 3975 39 56 2 1 0 1 -1 -1 0 0 -1 0.000 0 0 -1 1 0 2 … … 62 79 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3975 2850 150 150 3975 2850 4125 2850 63 80 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 7200 2775 150 150 7200 2775 7350 2775 64 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 2250 4830 30 30 2250 4830 2280 48 3081 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 2250 4830 30 30 2250 4830 2280 4860 65 82 1 3 0 1 0 0 0 0 0 0.000 1 0.0000 7200 2775 30 30 7200 2775 7230 2805 66 83 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3525 3600 150 150 3525 3600 3675 3600 67 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4625 4838 100 100 4625 4838 4725 4838 84 1 3 0 1 -1 -1 0 0 -1 0.000 1 0.0000 3875 4800 100 100 3875 4800 3975 4800 85 1 1 0 1 -1 -1 0 0 -1 0.000 1 0.0000 4650 4800 150 75 4650 4800 4800 4875 68 86 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 69 87 2400 4200 2400 3750 1950 3750 1950 4200 2400 4200 … … 135 153 1 1 1.00 45.00 90.00 136 154 7875 3750 7875 2325 7200 2325 7200 2550 155 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 156 5850 4950 5850 4725 5625 4725 5625 4950 5850 4950 137 157 2 2 1 1 -1 -1 0 0 -1 3.000 0 0 0 0 0 5 138 158 6975 4950 6750 4950 6750 4725 6975 4725 6975 4950 139 2 2 0 1 -1 -1 0 0 -1 0.000 0 0 0 0 0 5 140 5850 4950 5850 4725 5625 4725 5625 4950 5850 4950 141 4 1 -1 0 0 0 10 0.0000 2 135 900 5550 4425 Processors\001 142 4 1 -1 0 0 0 10 0.0000 2 165 1170 4200 3975 Ready Threads\001 143 4 1 -1 0 0 0 10 0.0000 2 165 1440 7350 1725 Other Cluster(s)\001 144 4 1 -1 0 0 0 10 0.0000 2 135 1080 4650 1725 User Cluster\001 145 4 1 -1 0 0 0 10 0.0000 2 165 630 2175 3675 Manager\001 146 4 1 -1 0 0 0 10 0.0000 2 135 1260 2175 3525 Discrete-event\001 147 4 1 -1 0 0 0 10 0.0000 2 150 900 2175 4350 preemption\001 148 4 0 -1 0 0 0 10 0.0000 2 135 630 7050 4875 cluster\001 149 4 1 -1 0 0 0 10 0.0000 2 135 1350 4200 3225 Blocked Threads\001 150 4 0 -1 0 0 0 10 0.0000 2 135 540 4800 4875 thread\001 151 4 0 -1 0 0 0 10 0.0000 2 120 810 5925 4875 processor\001 152 4 0 -1 0 0 0 10 0.0000 2 165 1710 2325 4875 generator/coroutine\001 159 4 1 -1 0 0 0 10 0.0000 2 105 720 5550 4425 Processors\001 160 4 1 -1 0 0 0 10 0.0000 2 120 1005 4200 3225 Blocked Tasks\001 161 4 1 -1 0 0 0 10 0.0000 2 150 870 4200 3975 Ready Tasks\001 162 4 1 -1 0 0 0 10 0.0000 2 135 1095 7350 1725 Other Cluster(s)\001 163 4 1 -1 0 0 0 10 0.0000 2 105 840 4650 1725 User Cluster\001 164 4 1 -1 0 0 0 10 0.0000 2 150 615 2175 3675 Manager\001 165 4 1 -1 0 0 0 10 0.0000 2 105 990 2175 3525 Discrete-event\001 166 4 1 -1 0 0 0 10 0.0000 2 135 795 2175 4350 preemption\001 167 4 0 -1 0 0 0 10 0.0000 2 150 1290 2325 4875 generator/coroutine\001 168 4 0 -1 0 0 0 10 0.0000 2 120 270 4050 4875 task\001 169 4 0 -1 0 0 0 10 0.0000 2 105 450 7050 4875 cluster\001 170 4 0 -1 0 0 0 10 0.0000 2 105 660 5925 4875 processor\001 171 4 0 -1 0 0 0 10 0.0000 2 105 555 4875 4875 monitor\001 -
doc/theses/thierry_delisle_PhD/thesis/glossary.tex
rf7e4f8e8 r4ae78c1 1 1 \makeglossaries 2 2 3 % ---------------------------------- 4 % Acronyms 5 \newacronym{api}{API}{Application Programming Interface} 6 \newacronym{fifo}{FIFO}{First-In, First-Out} 7 \newacronym{io}{I/O}{Input and Output} 8 \newacronym{numa}{NUMA}{Non-Uniform Memory Access} 9 \newacronym{raii}{RAII}{Resource Acquisition Is Initialization} 10 \newacronym{tls}{TLS}{Thread Local Storage} 3 \longnewglossaryentry{hthrd} 4 {name={hardware thread}} 5 { 6 Threads representing the underlying hardware directly. 11 7 12 % ---------------------------------- 13 % Definitions 8 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 9 } 14 10 15 11 \longnewglossaryentry{thrd} 16 {name={thread }}12 {name={threads}} 17 13 { 18 14 Threads created and managed inside user-space. Each thread has its own stack and its own thread of execution. User-level threads are invisible to the underlying operating system. 19 15 20 16 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.} 21 }22 23 \longnewglossaryentry{proc}24 {name={processor}}25 {26 27 }28 29 \longnewglossaryentry{rQ}30 {name={ready-queue}}31 {32 33 }34 35 \longnewglossaryentry{uthrding}36 {name={user-level threading}}37 {38 39 40 \textit{Synonyms : User threads, Lightweight threads, Green threads, Virtual threads, Tasks.}41 }42 43 % ----------------------------------44 45 \longnewglossaryentry{hthrd}46 {name={hardware thread}}47 {48 Threads representing the underlying hardware directly, \eg the CPU core, or hyper-thread if the hardware supports multiple threads of execution per core. The number of hardware threads is considered to be always fixed to a specific number determined by the hardware.49 50 \textit{Synonyms : }51 17 } 52 18 … … 91 57 } 92 58 59 \longnewglossaryentry{proc} 60 {name={virtual processor}} 61 { 93 62 63 } 64 65 \longnewglossaryentry{Q} 66 {name={work-queue}} 67 { 68 69 } 94 70 95 71 \longnewglossaryentry{at} … … 155 131 } 156 132 133 134 \newacronym{tls}{TLS}{Thread Local Storage} 135 \newacronym{api}{API}{Application Program Interface} 136 \newacronym{raii}{RAII}{Resource Acquisition Is Initialization} 137 \newacronym{numa}{NUMA}{Non-Uniform Memory Access} -
doc/theses/thierry_delisle_PhD/thesis/text/core.tex
rf7e4f8e8 r4ae78c1 1 1 \chapter{Scheduling Core}\label{core} 2 2 3 Before discussing scheduling in general, where it is important to address systems that are changing states, this document discusses scheduling in a somewhat ideal scenerio, where the system has reached a steady state. For this purpose, a steady state is loosely defined as a state where there are always \glspl{thrd} ready to run and but the system has the ressources necessary to accomplish the work. In short, the system is neither overloaded or underloaded. 3 This chapter addresses the need of scheduling on a somewhat ideal scenario 4 4 5 I believe it is important to discuss the steady state first because it is the easiest case to handle and, relatedly, the case in which the best performance is to be expected. As such, when the system is either overloaded or underloaded, a common approach is to try to adapt the system to the new load and return to the steady state. Flaws in the scheduling in the steady state tend therefore to be pervasive in all states. 5 \section{Existing Schedulers} 6 \subsection{Feedback Scheduling} 6 7 7 \section{Design Goals} 8 As with most of the design decisions behind \CFA, the main goal is to match the expectation of the programmer, according to their probable mental model. To match these expectations, the design must offer the programmers sufficient guarantees so that, as long as the programmer respects the mental model, the system will also respect this model. 8 \subsection{Priority Scheduling}\label{priority} 9 9 10 For threading, a simple and common mental model is the ``Ideal multi-tasking CPU'' : 11 12 \begin{displayquote}[Linux CFS\cit{https://www.kernel.org/doc/Documentation/scheduler/sched-design-CFS.txt}] 13 {[The]} ``Ideal multi-tasking CPU'' is a (non-existent :-)) CPU that has 100\% physical power and which can run each task at precise equal speed, in parallel, each at [an equal fraction of the] speed. For example: if there are 2 tasks running, then it runs each at 50\% physical power --- i.e., actually in parallel. 14 \end{displayquote} 15 16 Applied to threads, this model states that every ready \gls{thrd} immediately runs in parallel with all other ready \glspl{thrd}. While a strict implementation of this model is not feasible, programmers still have expectations about scheduling that come from this model. 17 18 In general, the expectation at the center of this model is that ready \glspl{thrd} do not interfere with eachother but simply share the hardware. This makes it easier to reason about threading because ready \glspl{thrd} can be taken in isolation and the effect of the scheduler can be virtually ignored. This expectation of \gls{thrd} independence means the scheduler is expected to offer 2 guarantees: 19 \begin{enumerate} 20 \item A fairness guarantee: a \gls{thrd} that is ready to run will not be prevented to do so by another thread. 21 \item A performance guarantee: a \gls{thrd} that wants to start or stop running will not be slowed down by other threads wanting to do the same. 22 \end{enumerate} 23 24 It is important to note that these guarantees are expected only up to a point. \Glspl{thrd} that are ready to run should not be prevented to do so, but they still need to share a limited amount of hardware. Therefore, the guarantee is considered respected if a \gls{thrd} gets access to a \emph{fair share} of the hardware, even if that share is very small. 25 26 Similarly the performance guarantee, the lack of interferance between threads is only relevant op to a point. Ideally the cost of running and blocking would be constant regardless of contention, but the guarantee is considered satisfied if the cost is not \emph{too high} with or without contention. How much is an acceptable cost is obviously highly variable. For this document the performance experimentation will attempt to show that the cost of scheduling is not a major factor in application performance. This demonstration can be made by comparing application built in \CFA to applications built with other languages or other models. If the performance of an application built in \CFA is not meaningfully different than one built with a different runtime, then the scheduler has a negigeable impact on performance, \ie its impact can be ignored. Recall from a few paragraphs ago that the expectation of programmers is that the impact of the scheduler can be ignored. Therefore, if the cost of scheduling is not a significant portion of the runtime of several different application, I will consider the guarantee achieved. 27 28 \todo{This paragraph should be moved later} 29 % The next step is then to decide what is considered a \emph{fair share}, \ie what metric is used to measure fairness. Since \CFA is intended to allow numerous short lived threads, I decided to avoid total CPU time as the measure of fairness. Total CPU time inherently favors new \glspl{thrd} over older ones which isn't necessarily a good thing. Instead, fairness is measured in terms of opportunities to run. This metric is more appropriate for a mix of short and long lived \glspl{thrd}. 10 \subsection{Work Stealing} 30 11 31 12 \section{Design} 32 While avoiding the pitfalls of Feedback Scheduling is fairly easy, scheduling does not innately require feedback, avoiding prioritization of \glspl{thrd} is more difficult because of implicitly priorities, see Subsection~\ref{priority}. A strictly \glsxtrshort{fifo} rea13 While avoiding the pitfalls of Feedback Scheduling is fairly easy, scheduling does not innately require feedback, avoiding prioritization of \glspl{thrd} is more difficult because of implicitly priorities, see Subsection~\ref{priority}. 33 14 34 15 \subsection{Sharding} … … 38 19 \input{base.pstex_t} 39 20 \end{center} 40 \caption{Relaxed FIFO list} 21 \caption{Relaxed FIFO list at the base of the scheduler: an array of strictly FIFO lists. 22 The timestamp is in all nodes and cell arrays.} 41 23 \label{fig:base} 42 List at the base of the scheduler: an array of strictly FIFO lists.43 The timestamp is in all nodes and cell arrays.44 24 \end{figure} 45 25 … … 48 28 Indeed, if the number of \glspl{thrd} does not far exceed the number of queues, it is probable that several of these queues are empty. 49 29 Figure~\ref{fig:empty} shows an example with 2 \glspl{thrd} running on 8 queues, where the chances of getting an empty queue is 75\% per pick, meaning two random picks yield a \gls{thrd} only half the time. 30 This can lead to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses. 31 32 Solutions to this problem can take many forms, but they ultimately all have to encode where the threads are in some form. My results show that the density and locality of this encoding is generally the dominating factor in these scheme. 33 34 \paragraph{Dense Information} 35 36 37 50 38 51 39 … … 54 42 \input{empty.pstex_t} 55 43 \end{center} 56 \caption{``More empty'' Relaxed FIFO list}44 \caption{``More empty'' state of the queue: the array contains many empty cells.} 57 45 \label{fig:empty} 58 Emptier state of the queue: the array contains many empty cells, that is strictly FIFO lists containing no elements.59 46 \end{figure} 60 61 This can lead to performance problems since picks that do not yield a \gls{thrd} are not useful and do not necessarily help make more informed guesses.62 63 Solutions to this problem can take many forms, but they ultimately all have to encode where the threads are in some form. My results show that the density and locality of this encoding is generally the dominating factor in these scheme.64 65 \paragraph{Dense Information} -
doc/theses/thierry_delisle_PhD/thesis/text/front.tex
rf7e4f8e8 r4ae78c1 184 184 \phantomsection % allows hyperref to link to the correct page 185 185 186 % TODOs and missing citations187 % -----------------------------188 186 \listofcits 189 187 \listoftodos 190 \cleardoublepage191 \phantomsection % allows hyperref to link to the correct page192 188 193 189 -
doc/theses/thierry_delisle_PhD/thesis/text/intro.tex
rf7e4f8e8 r4ae78c1 1 \chapter*{Introduction}\label{intro} 2 \todo{A proper intro} 3 4 The C programming language\cit{C} 5 6 The \CFA programming language\cite{cfa:frontpage,cfa:typesystem} which extends the C programming language to add modern safety and productiviy features while maintaining backwards compatibility. Among it's productiviy features, \CFA introduces support for threading\cit{CFA Concurrency}, to allow programmers to write modern concurrent and parallel programming. 7 While previous work on the concurrent package of \CFA focused on features and interfaces, this thesis focuses on performance, introducing \glsxtrshort{api} changes only when required by performance considerations. More specifically, this thesis concentrates on scheduling and \glsxtrshort{io}. Prior to this work, the \CFA runtime used a strictly \glsxtrshort{fifo} \gls{rQ}. 8 9 This work exclusively concentrates on Linux as it's operating system since the existing \CFA runtime and compiler does not already support other operating systems. Furthermore, as \CFA is yet to be released, supporting version of Linux older that the latest version is not a goal of this work. 1 \chapter{Introduction} -
doc/theses/thierry_delisle_PhD/thesis/text/io.tex
rf7e4f8e8 r4ae78c1 1 \chapter{User Level \glsxtrshort{io}} 2 As mentionned in Section~\ref{prev:io}, User-Level \glsxtrshort{io} requires multiplexing the \glsxtrshort{io} operations of many \glspl{thrd} onto fewer \glspl{proc} using asynchronous \glsxtrshort{io} operations. Various operating systems offer various forms of asynchronous operations and as mentioned in Chapter~\ref{intro}, this work is exclusively focuesd on Linux. 1 \chapter{I/O} 3 2 4 3 \section{Existing options} 5 Since \glsxtrshort{io} operations are generally handled by the6 4 7 5 \subsection{\texttt{epoll}, \texttt{poll} and \texttt{select}} … … 9 7 \subsection{Linux's AIO} 10 8 9 \subsection{\texttt{io\_uring}} 11 10 12 13 \begin{displayquote} 14 AIO is a horrible ad-hoc design, with the main excuse being "other, 15 less gifted people, made that design, and we are implementing it for 16 compatibility because database people - who seldom have any shred of 17 taste - actually use it". 18 19 But AIO was always really really ugly. 20 21 \begin{flushright} 22 -- Linus Torvalds\cit{https://lwn.net/Articles/671657/} 23 \end{flushright} 24 \end{displayquote} 25 26 Interestingly, in this e-mail answer, Linus goes on to describe 27 ``a true \textit{asynchronous system call} interface'' 28 that does 29 ``[an] arbitrary system call X with arguments A, B, C, D asynchronously using a kernel thread'' 30 in 31 ``some kind of arbitrary \textit{queue up asynchronous system call} model''. 32 This description is actually quite close to the interface of the interface described in the next section. 33 34 \subsection{\texttt{io\_uring}} 35 A very recent addition to Linux, \texttt{io\_uring}\cit{io\_uring} is a framework that aims to solve many of the problems listed with the above mentioned solutions. 36 37 \subsection{Extra Kernel Threads}\label{io:morethreads} 38 Finally, if the operating system does not offer any satisfying forms of asynchronous \glsxtrshort{io} operations, a solution is to fake it by creating a pool of \glspl{kthrd} and delegating operations to them in order to avoid blocking \glspl{proc}. 11 \subsection{Extra Kernel Threads} 39 12 40 13 \subsection{Discussion} -
doc/theses/thierry_delisle_PhD/thesis/text/practice.tex
rf7e4f8e8 r4ae78c1 2 2 The scheduling algorithm discribed in Chapter~\ref{core} addresses scheduling in a stable state. 3 3 However, it does not address problems that occur when the system changes state. 4 Indeed the \CFA runtime, supports expanding and shrinking the number of KTHREAD\_place \todo{add kthrd to glossary}, both manually and, to some extent automatically. 4 Indeed the \CFA runtime, supports expanding and shrinking 5 6 the number of KTHREAD\_place 7 8 , both manually and, to some extent automatically. 5 9 This entails that the scheduling algorithm must support these transitions. 6 10 -
doc/theses/thierry_delisle_PhD/thesis/text/runtime.tex
rf7e4f8e8 r4ae78c1 1 1 \chapter{\CFA Runtime} 2 This chapter offers an overview of the capabilities of the \CFA runtime prior to this work.3 2 4 Threading in \CFA offers is based on \Gls{uthrding}, where \glspl{thrd} are the representation of a unit of work. As such, \CFA programmers should expect these units to be fairly inexpensive, that is: programmers should be able to create a large number of \glspl{thrd} and switch between \glspl{thrd} liberally without many concerns for performance. 5 6 \section{M:N Threading}\label{prev:model} 7 8 C traditionnally uses a 1:1 threading model. This model uses \glspl{kthrd} to achive parallelism and concurrency. In this model, every thread of computation maps to an object in the kernel. The kernel then has the responsibility of managing these threads, \eg creating, scheduling, blocking. This also entails that the kernel has a perfect view of every thread executing in the system\footnote{This is not completly true due to primitives like \texttt{futex}es, which have a significant portion of their logic in user space.}. 9 10 By contrast \CFA uses an M:N threading models, where concurrency is achieved using many user-level threads mapped onto fewer \glspl{kthrd}. The user-level threads have the same semantic meaning as a \glspl{kthrd} in the 1:1 model, they represent an independant thread of execution with it's on stack. The difference is that user-level threads do not have a corresponding object in the kernel, they are handled by the runtime in user space and scheduled onto \glspl{kthrd}, referred to as \glspl{proc} in this document. \Glspl{proc} run a \gls{thrd} until it context switches out, it then choses a different \gls{thrd} to run. 3 \section{M:N Threading} 11 4 12 5 \section{Clusters} 13 \begin{figure}14 \begin{center}15 \input{system.pstex_t}16 \end{center}17 \caption{Overview of the \CFA runtime}18 \label{fig:system}19 \Glspl{thrd} are scheduled inside a particular cluster, where it only runs on the \glspl{proc} which belong to the cluster. The discrete-event manager, which handles preemption and timeout, is a \gls{kthrd} which lives outside any cluster and does not run \glspl{thrd}.20 \end{figure}21 \CFA allows the option to group user-level threading, in the form of clusters. Both \glspl{thrd} and \glspl{proc} belong to a specific cluster. \Glspl{thrd} will only be scheduled onto \glspl{proc} in the same cluster and scheduling is done independantly of other clusters. Figure~\ref{fig:system} shows an overview if this system. This allows programmers to control more tightly parallelism. It also opens the door to handling effects like NUMA, by pining clusters to specific NUMA node\footnote{This is not currently implemented in \CFA, but the only hurdle left is creating a generic interface for cpu masks.}.22 23 \section{Scheduling}24 The \CFA runtime was previously using a strictly \glsxtrshort{fifo} ready queue with a single lock. This setup offers perfect fairness in terms of opportunities to run/ However, it offers poor scalability, since the performance of the ready queue can never be improved by adding more \glspl{hthrd}, but the contention can cause significant performance degradation.25 26 \section{\glsxtrshort{io}}\label{prev:io}27 Prior to this work, the \CFA runtime did not add any particular support for \glsxtrshort{io} operations. \CFA being built on C, this means that, while all the operations available in C are available in \CFA, \glsxtrshort{io} operations are designed for the POSIX threading model\cit{pthreads}. Using these operations in a M:N threading model, when they are built for 1:1 threading, means that operations block \glspl{proc} instead of \glspl{thrd}. While this can work in certain cases, it limits the number of concurrent operations to the number of \glspl{proc} rather than \glspl{thrd}. This also means that deadlocks can occur because all \glspl{proc} are blocked even if at least one \gls{thrd} is ready to run. A simple example of this type of deadlock would be as follows:28 29 Given a simple network program with 2 \glspl{thrd} and a single \gls{proc}, one \gls{thrd} sends network requests to a server and the other \gls{thrd} waits for response from the server. If the second \gls{thrd} races ahead, it may wait for responses to requests that have not been sent yet. In theory, this should not be a problem, even if the second \gls{thrd} waits, the first \gls{thrd} is still ready to run and should just be able to get CPU time and send the request. In practice with M:N threading, while the first \gls{thrd} is ready, the lone \gls{proc} in this example will \emph{not} try to run the first \gls{thrd} if it is blocked in the \glsxtrshort{io} operation of the second \gls{thrd}. If this happen, the system is effectively deadlocked\footnote{In this example, the deadlocked could be resolved if the server sends unprompted messages to the client. However, this solution is not general and may not be appropriate even in this simple case.}.30 31 One of the objective of this work, is to introduce \emph{User-Level \glsxtrshort{io}} which, as a parallel to \glslink{uthrding}{User-Level \emph{Threading}}, blocks \glspl{thrd} rather than \glspl{proc} when doing \glsxtrshort{io} operations. This entails multiplexing the \glsxtrshort{io} operations of many \glspl{thrd} onto fewer \glspl{proc}. This multiplexing requires that a single \gls{proc} be able to execute multiple operations in parallel. This cannot be done with operations that block \glspl{proc}, \ie \glspl{kthrd}, since the first operation would prevent starting new operations for its duration. Executing operations in parallel requires \emph{asynchronous} \glsxtrshort{io}, sometimes referred to as \emph{non-blocking}, since the \gls{kthrd} is not blocked.32 6 33 7 \section{Interoperating with \texttt{C}} 34 While \glsxtrshort{io} operations are the classical example of operations that block \glspl{kthrd}, the challenges mentioned in the previous section do not require \glsxtrshort{io} to be involved. These challenges are a product of blocking system calls rather than \glsxtrshort{io}. C offers no tools to identify whether or not a librairy function will lead to a blocking system call. This fact means interoperatability with C becomes a challenge in a M:N threading model.35 36 Languages like Go and Java, which have strict interoperatability with C\cit{JNI, GoLang with C}, can control operations in C by ``sandboxing'' them. They can, for example, delegate C operations to \glspl{kthrd} that are not \glspl{proc}. Sandboxing may help towards guaranteeing that the deadlocks mentioned in the previous section do not occur.37 38 As mentioned in Section~\cit{\CFA intro}, \CFA is binary compatible with C and, as such, trivially supports calls to and from C librairies. Furthermore, interoperatability can happen within a single library, through inline code or simply C and \CFA translation units archived together. The fine-grained interoperatability between C and \CFA has two consequences:39 \begin{enumerate}40 \item Precisely identifying C calls that could block is difficult.41 \item Introducing code where interoperatability occurs could have a significant impact on general performance.42 \end{enumerate}43 44 Because of these consequences, this work does not attempt to ``sandbox'' calls to C. It is possible that conflicting calls to C could lead to deadlocks on \CFA's M:N threading model where they would not in the traditionnal 1:1 threading model. However, I judge that solving this problem in general, in a way that is composable and flexible, is too complex in itself and would add too much work to this thesis. Therefore it is outside the scope of this thesis. -
doc/theses/thierry_delisle_PhD/thesis/thesis.tex
rf7e4f8e8 r4ae78c1 121 121 % installation instructions there. 122 122 123 \usepackage{csquotes}124 \usepackage{indentfirst} % as any self-respecting frenchman would125 126 123 % Setting up the page margins... 127 124 % uWaterloo thesis requirements specify a minimum of 1 inch (72pt) margin at the … … 221 218 % separate documents, they would each start with the \chapter command, i.e, 222 219 % do not contain \documentclass or \begin{document} and \end{document} commands. 223 \part{Introduction}224 220 \input{text/intro.tex} 225 \input{text/existing.tex}226 221 \input{text/runtime.tex} 227 \part{Design}228 222 \input{text/core.tex} 229 223 \input{text/practice.tex} 230 224 \input{text/io.tex} 231 \part{Evaluation}232 \chapter{Theoretical and Existance Proofs}233 \chapter{Micro-Benchmarks}234 \chapter{Larger-Scale applications}235 \part{Conclusion \& Annexes}236 225 237 226 %---------------------------------------------------------------------- … … 256 245 \addcontentsline{toc}{chapter}{\textbf{References}} 257 246 258 \bibliography{ local}247 \bibliography{uw-ethesis} 259 248 % Tip 5: You can create multiple .bib files to organize your references. 260 249 % Just list them all in the \bibliogaphy command, separated by commas (no spaces). 261 250 262 % %The following statement causes the specified references to be added to the bibliography% even if they were not263 % %cited in the text. The asterisk is a wildcard that causes all entries in the bibliographic database to be included (optional).264 %\nocite{*}251 % The following statement causes the specified references to be added to the bibliography% even if they were not 252 % cited in the text. The asterisk is a wildcard that causes all entries in the bibliographic database to be included (optional). 253 \nocite{*} 265 254 266 255 % The \appendix statement indicates the beginning of the appendices.
Note:
See TracChangeset
for help on using the changeset viewer.