Changes in / [4852232:17c13b9]
- Location:
- doc/theses/colby_parsons_MMAth/text
- Files:
-
- 6 edited
-
actors.tex (modified) (8 diffs)
-
channels.tex (modified) (1 diff)
-
conclusion.tex (modified) (1 diff)
-
intro.tex (modified) (1 diff)
-
mutex_stmt.tex (modified) (1 diff)
-
waituntil.tex (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/theses/colby_parsons_MMAth/text/actors.tex
r4852232 r17c13b9 251 251 Therefore, it is up to the actor program to manage message life-time across receives. 252 252 However, for a message to appear on multiple message queues, it needs an arbitrary number of associated destination behaviours. 253 Hence, there is the concept of an envelop e, which is dynamically allocated on each send, that wraps a message with any extra implementation fields needed to persist between send and receive.254 Managing the envelop e is straightforward because it is created at the send and deleted after the receive, \ie there is 1:1 relationship for an envelopeand a many to one relationship for a message.253 Hence, there is the concept of an envelop, which is dynamically allocated on each send, that wraps a message with any extra implementation fields needed to persist between send and receive. 254 Managing the envelop is straightforward because it is created at the send and deleted after the receive, \ie there is 1:1 relationship for an envelop and a many to one relationship for a message. 255 255 256 256 % In actor systems, messages are sent and received by actors. … … 342 342 343 343 Users could be expected to write the @?|?@ routines, but this approach is error prone and creates maintenance issues. 344 As a stopgap until the \CFA type-system matures, a workaround was created using a template-like approach, where the compiler generates a matching @?|?@ routine for each @receive@ routine it finds with the correct actor/message type-signature.345 This workaround is outside of the type system, but perform sa type-system like action.344 Until the \CFA type-system matures, I created a workaround using a template-like approach, where the compiler generates a matching @?|?@ routine for each @receive@ routine it finds with the correct actor/message type-signature. 345 This workaround is outside of the type system, but performing a type-system like action. 346 346 The workaround requires no annotation or additional code to be written by users; 347 347 thus, it resolves the maintenance and error problems. … … 352 352 The routine sets @rec_fn@ to the matching @receive@ routine using the left-hand type to perform the selection. 353 353 Then the routine packages the actor and message, along with the receive routine into an envelope. 354 Finally, the envelop eis added to the executor queue designated by the actor using the executor routine @send@.354 Finally, the envelop is added to the executor queue designated by the actor using the executor routine @send@. 355 355 356 356 \begin{figure} … … 396 396 \subsection{Actor Termination}\label{s:ActorTerm} 397 397 During a message send, the receiving actor and message being sent are stored via pointers in the envelope. 398 These pointers have the base actor and message types, so type information of the derived actor and message is lost and must be recovered later when the typed receive routine is called.398 These pointers are the base actor and message types, so type information of the derived actor and message is lost and must be recovered later when the typed receive routine is called. 399 399 After the receive routine is done, the executor must clean up the actor and message according to their allocation status. 400 400 If the allocation status is @Delete@ or @Destroy@, the appropriate destructor must be called by the executor. … … 402 402 the derived type of the actor or message is not available to the executor, but it needs to call the derived destructor. 403 403 This requires downcasting from the base type to the derived type, which requires a virtual system. 404 To accomplish the dow ncast, a rudimentary destructor-only virtual system was implemented in \CFA as part of this work.404 To accomplish the dowcast, I implemented a rudimentary destructor-only virtual system in \CFA. 405 405 This virtual system is used via Plan-9 inheritance of the @virtual_dtor@ type, shown in Figure~\ref{f:VirtDtor}. 406 406 The @virtual_dtor@ type maintains a pointer to the start of the object, and a pointer to the correct destructor. … … 517 517 518 518 Since the copy queue is an array, envelopes are allocated first on the stack and then copied into the copy queue to persist until they are no longer needed. 519 For many workload s, the copy queues grow in size to facilitate the average number of messages in flight and there areno further dynamic allocations.519 For many workload, the copy queues grow in size to facilitate the average number of messages in flight and there is no further dynamic allocations. 520 520 The downside of this approach is that more storage is allocated than needed, \ie each copy queue is only partially full. 521 521 Comparatively, the individual envelope allocations of a list-based queue mean that the actor system always uses the minimum amount of heap space and cleans up eagerly. … … 662 662 However, any form of locking here creates contention between thief and victim. 663 663 664 The alternative to locking is allowing the race and resolving it lazily .664 The alternative to locking is allowing the race and resolving it lazily (lock-free approach). 665 665 % As mentioned, there is a race between a victim gulping and a thief stealing because gulping partitions a mailbox queue making it ineligible for stealing. 666 666 % Furthermore, after a thief steals, there is moment when victim gulps but the queue no longer … … 1262 1262 Because $Z$ is contiguous in memory, there can be small cache write-contention at the row boundaries. 1263 1263 1264 Figures~\ref{f:MatrixAMD} and \ref{f:MatrixIntel} show the matrix -multiplyresults.1264 Figures~\ref{f:MatrixAMD} and \ref{f:MatrixIntel} show the matrix multiple results. 1265 1265 There are two groupings with Akka and ProtoActor being slightly slower than \uC, \CFA, and CAF. 1266 1266 On the Intel, there is an unknown divergence between \uC and \CFA/CAF at 24 cores. -
doc/theses/colby_parsons_MMAth/text/channels.tex
r4852232 r17c13b9 106 106 \item A @flush@ routine that delivers copies of an element to all waiting consumers, flushing the buffer. 107 107 Programmers use this mechanism to broadcast a sentinel value to multiple consumers. 108 Additionally, the @flush@ routine is more performant th an looping around the @insert@ operation since it can deliver the elements without having to reacquire mutual exclusion for each element sent.108 Additionally, the @flush@ routine is more performant then looping around the @insert@ operation since it can deliver the elements without having to reacquire mutual exclusion for each element sent. 109 109 110 110 \item Go-style @?<<?@ shorthand operator for inserting and removing. -
doc/theses/colby_parsons_MMAth/text/conclusion.tex
r4852232 r17c13b9 14 14 \begin{enumerate} 15 15 \item The mutex statement, which provides performant and deadlock-free multiple lock acquisition. 16 \item Channels with comparable performance to Go, that have safety and productivity features including deadlock detection ,and an easy-to-use exception-based channel @close@ routine.16 \item Channels with comparable performance to Go, that have safety and productivity features including deadlock detection and an easy-to-use exception-based channel @close@ routine. 17 17 \item An in-memory actor system that achieved the lowest latency message send of systems tested due to the novel copy-queue data structure. The actor system presented has built-in detection of six common actor errors, and it has good performance compared to other systems on all benchmarks. 18 18 \item A @waituntil@ statement which tackles the hard problem of allowing a thread to safely synchronously wait for some set of concurrent resources. -
doc/theses/colby_parsons_MMAth/text/intro.tex
r4852232 r17c13b9 14 14 This thesis builds on top of that foundation by providing a suite of high-level concurrent features. 15 15 The features include a @mutex@ statement, channels, a @waituntil@ statement, and an actor system. 16 All of these features exist in other programming languagesin some shape or form, however this thesis extends the original ideas by improving performance, productivity, and safety.16 All of these features exist in other programming in some shape or form, however this thesis extends the original ideas by improving performance, productivity, and safety. -
doc/theses/colby_parsons_MMAth/text/mutex_stmt.tex
r4852232 r17c13b9 83 83 \end{figure} 84 84 85 Like Java, \CFA monitors have \Newterm{multi-acquire} semantics so the thread in the monitor may acquire it multiple times without deadlock, allowing recursion and calling o f other MX functions.85 Like Java, \CFA monitors have \Newterm{multi-acquire} semantics so the thread in the monitor may acquire it multiple times without deadlock, allowing recursion and calling other MX functions. 86 86 For robustness, \CFA monitors ensure the monitor lock is released regardless of how an acquiring function ends, normal or exceptional, and returning a shared variable is safe via copying before the lock is released. 87 87 Monitor objects can be passed through multiple helper functions without acquiring mutual exclusion, until a designated function associated with the object is called. 88 88 \CFA functions are designated MX by one or more pointer/reference parameters having qualifier @mutex@. 89 89 Java members are designated MX with \lstinline[language=java]{synchronized}, which applies only to the implicit receiver parameter. 90 In the example above, the increment and setter operations need mutual exclusion, while the read-only getter operation is not MX because reading an integer is atomic.90 In the example, the increment and setter operations need mutual exclusion, while the read-only getter operation is not MX because reading an integer is atomic. 91 91 92 92 As stated, the non-object-oriented nature of \CFA monitors allows a function to acquire multiple mutex objects. -
doc/theses/colby_parsons_MMAth/text/waituntil.tex
r4852232 r17c13b9 163 163 164 164 Another example of programming-language \gls{synch_multiplex} is Go using a @select@ statement with channels~\cite{go:selectref}. 165 Figure~\ref{l:BB_Go} shows the outline of a bounded buffer administratorimplemented with a Go routine.165 Figure~\ref{l:BB_Go} shows the outline of a bounded buffer implemented with a Go routine. 166 166 Here two channels are used for inserting and removing by client producers and consumers, respectively. 167 (The @ done@ channel isused to synchronize with the program main.)167 (The @term@ and @stop@ channels are used to synchronize with the program main.) 168 168 Go's @select@ has the same exclusive-or semantics as the ALT primitive from Occam and associated code blocks for each clause like ALT and Ada. 169 169 However, unlike Ada and ALT, Go does not provide guards for the \lstinline[language=go]{case} clauses of the \lstinline[language=go]{select}. 170 As such, the exponential blowup can be seen comparing Go and \uC in Figure~\label{f:AdaMultiplexing}.171 170 Go also provides a timeout via a channel and a @default@ clause like Ada @else@ for asynchronous multiplexing. 172 171 … … 176 175 \begin{lrbox}{\myboxA} 177 176 \begin{lstlisting}[language=go,literate=] 178 insert := make( chan int )179 remove := make( chan * int )180 buffer := make( chan int Size )181 done := make( chan int )182 count := 0183 func in_buf( int val ) {184 buffer <- val185 count++186 }187 func out_buf( int * ptr ) {188 *ptr := <-buffer189 count--190 }191 func BoundedBuffer {192 L: for {193 if ( count < Size && count > 0 ) {194 select { // wait for message195 case i := <- insert: in_buf( i )196 case p := <- remove: out_buf( p )197 case <- done: break L198 }199 } else if ( count < Size ) {200 select { // wait for message201 case i := <- insert: in_buf( i )202 case <- done: break L203 }204 } else ( count > 0 ) {205 select { // wait for message206 case p := <- remove: out_buf( p )207 case <- done: break L;208 }209 }210 }211 done <- 0212 }213 177 func main() { 214 go BoundedBuffer() // start administrator 178 insert := make( chan int, Size ) 179 remove := make( chan int, Size ) 180 term := make( chan string ) 181 finish := make( chan string ) 182 183 buf := func() { 184 L: for { 185 select { // wait for message 186 case i = <- buffer: 187 case <- term: break L 188 } 189 remove <- i; 190 } 191 finish <- "STOP" // completion 192 } 193 go buf() // start thread in buf 215 194 } 216 195 … … 224 203 \begin{lstlisting}[language=uC++=] 225 204 _Task BoundedBuffer { 226 int * buffer;227 int front = back =count = 0;205 ... // buffer declarations 206 int count = 0; 228 207 public: 229 // ... constructor implementation230 208 void insert( int elem ) { 231 buffer[front] = elem; 232 front = ( front + 1 ) % Size; 209 ... // add to buffer 233 210 count += 1; 234 211 } 235 212 int remove() { 236 int ret = buffer[back]; 237 back = ( back + 1 ) % Size; 213 ... // remove and return from buffer 238 214 count -= 1; 239 return ret;240 215 } 241 216 private: … … 265 240 The @_Select@ statement extends the ALT/Go @select@ by offering both @and@ and @or@ semantics, which can be used together in the same statement. 266 241 Both @_Accept@ and @_Select@ statements provide guards for multiplexing clauses, as well as, timeout, and @else@ clauses. 267 Figure~\ref{l:BB_uC++} shows the outline of a bounded buffer administrator implemented with \uC @_Accept@ statements.268 242 269 243 There are other languages that provide \gls{synch_multiplex}, including Rust's @select!@ over futures~\cite{rust:select}, OCaml's @select@ over channels~\cite{ocaml:channel}, and C++14's @when_any@ over futures~\cite{cpp:whenany}. … … 767 741 when_conditions[node] = true; 768 742 769 if ( any when_conditions[node] aretrue ) {770 select_nodes nodes[N]; $\C{// declare N select nodes}$ 771 try { 772 // ... set statuses for nodes with when_conditions[node] == false ... 773 774 for ( node in nodes ) $\C{// register nodes}$ 775 if ( when_conditions[node] )776 register_select( resource, node );777 778 while ( !check_completion( nodes ) ) { $\C{// check predicate}$ 779 // block780 for ( resource in waituntil statement ) { $\C{// run true code blocks}$781 if ( check_completion( nodes ) ) break;782 if ( resource is avail )783 try {784 if( on_selected( resource ) ) $\C{// conditionally run block}$785 run code block786 } finally $\C{// for exception safety}$787 unregister_select( resource, node ); $\C{// immediate unregister}$788 }743 if ( any when_conditions[node] == true ) { 744 745 select_nodes nodes[N]; $\C{// declare N select nodes}$ 746 try { 747 // ... set statuses for nodes with when_conditions[node] == false ... 748 749 for ( node in nodes ) $\C{// register nodes}$ 750 if ( when_conditions[node] ) 751 register_select( resource, node ); 752 753 while ( !check_completion( nodes ) ) { $\C{// check predicate}$ 754 // block 755 for ( resource in waituntil statement ) { $\C{// run true code blocks}$ 756 if ( check_completion( nodes ) ) break; 757 if ( resource is avail ) 758 try { 759 if( on_selected( resource ) ) $\C{// conditionally run block}$ 760 run code block 761 } finally $\C{// for exception safety}$ 762 unregister_select( resource, node ); $\C{// immediate unregister}$ 789 763 } 790 } finally { $\C{// for exception safety}$791 for ( registered nodes in nodes ) $\C{// deregister nodes}$792 if ( when_conditions[node] && unregister_select( resource, node )793 && on_selected( resource ) )794 run code block $\C{// run code block upon unregister}\CRT$795 764 } 765 } finally { $\C{// for exception safety}$ 766 for ( registered nodes in nodes ) $\C{// deregister nodes}$ 767 if ( when_conditions[node] && unregister_select( resource, node ) 768 && on_selected( resource ) ) 769 run code block $\C{// run code block upon unregister}\CRT$ 770 } 771 796 772 } 797 773 \end{cfa} … … 938 914 \setlength{\tabcolsep}{5pt} 939 915 940 \caption{Throughput (channel operations per second) of \CFA and Go in a pathologicalcase for contention in Go's select implementation}916 \caption{Throughput (channel operations per second) of \CFA and Go for a pathologically case for contention in Go's select implementation} 941 917 \label{t:pathGo} 942 918 \begin{tabular}{r|r|r}
Note:
See TracChangeset
for help on using the changeset viewer.