Publicação
Making Session Types Go
| Resumo: | The ubiquitous nature of today’s multi-core processors means concurrency is ever more important to effectively use available computing resources. By its very nature however, concurrent programming is complex and error-prone - accounting for random process interleavings and managing shared resource control is difficult and can lead to instances of incorrect behavior or deadlocks in concurrent programs. As such, ensuring the cor- rectness of concurrent programs is of the utmost importance. Session types are a typing discipline for message-passing concurrency that is able to ensure strong compile-time correctness guarantees for concurrent programs by providing a protocols-as-types view of communication. In particular, we make use of the interpretation of intuitionistic linear logic formulas as session types, which serves as the basis for logical session types. These logical session types offer stronger guarantees at compile-time than simple session types. In this work we implement a (logically) session-typed functional language, along with its associated type checker, and develop a compiler for said language targeting the Go language. Our work features standard functional programming features combined with channel-based, session-typed, concurrency primitives and thread spawning. Concurrency and pure functional values are separated via a monad-like interface, in the style of Haskell. Our compilation pipeline takes a program, type checks it to ensure the absence of dead- locks and communication errors, and then translates it to valid Go code, leveraging Go’s channel and lightweight thread infrastructure. The translation requires compensating the mismatch between Go’s channel types and session types, which we achieve via a state machine view of session types. We showcase the expressiveness of our language via a series of examples, encoding concurrency idioms in the style of map-reduce, among others. We also perform a performance evaluation of our implementation, experimenting with different settings and testing it against a native Go implementation. We follow with a discussion of the experimental results. Finally, we end by discussing possible approaches to future work, namely in terms of compiler optimizations and increase in language expressiveness. |
|---|---|
| Autores principais: | Geraldo, João Miguel Pereira do Cano Rico |
| Assunto: | Concurrency Session Types Logical Session Types Compilation Go Functional Language |
| Ano: | 2022 |
| País: | Portugal |
| Tipo de documento: | dissertação de mestrado |
| Tipo de acesso: | acesso aberto |
| Instituição associada: | Universidade Nova de Lisboa |
| Idioma: | inglês |
| Origem: | Repositório Institucional da UNL |
| Resumo: | The ubiquitous nature of today’s multi-core processors means concurrency is ever more important to effectively use available computing resources. By its very nature however, concurrent programming is complex and error-prone - accounting for random process interleavings and managing shared resource control is difficult and can lead to instances of incorrect behavior or deadlocks in concurrent programs. As such, ensuring the cor- rectness of concurrent programs is of the utmost importance. Session types are a typing discipline for message-passing concurrency that is able to ensure strong compile-time correctness guarantees for concurrent programs by providing a protocols-as-types view of communication. In particular, we make use of the interpretation of intuitionistic linear logic formulas as session types, which serves as the basis for logical session types. These logical session types offer stronger guarantees at compile-time than simple session types. In this work we implement a (logically) session-typed functional language, along with its associated type checker, and develop a compiler for said language targeting the Go language. Our work features standard functional programming features combined with channel-based, session-typed, concurrency primitives and thread spawning. Concurrency and pure functional values are separated via a monad-like interface, in the style of Haskell. Our compilation pipeline takes a program, type checks it to ensure the absence of dead- locks and communication errors, and then translates it to valid Go code, leveraging Go’s channel and lightweight thread infrastructure. The translation requires compensating the mismatch between Go’s channel types and session types, which we achieve via a state machine view of session types. We showcase the expressiveness of our language via a series of examples, encoding concurrency idioms in the style of map-reduce, among others. We also perform a performance evaluation of our implementation, experimenting with different settings and testing it against a native Go implementation. We follow with a discussion of the experimental results. Finally, we end by discussing possible approaches to future work, namely in terms of compiler optimizations and increase in language expressiveness. |
|---|