Making Session Types Go
Main Author: | |
---|---|
Publication Date: | 2022 |
Format: | Master thesis |
Language: | eng |
Source: | Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) |
Download full: | http://hdl.handle.net/10362/151153 |
Summary: | 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. |
id |
RCAP_24d3d0b57a89c75dbd919c736df2e69d |
---|---|
oai_identifier_str |
oai:run.unl.pt:10362/151153 |
network_acronym_str |
RCAP |
network_name_str |
Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) |
repository_id_str |
https://opendoar.ac.uk/repository/7160 |
spelling |
Making Session Types GoConcurrencySession TypesLogical Session TypesCompilationGoFunctional LanguageDomínio/Área Científica::Engenharia e Tecnologia::Engenharia Eletrotécnica, Eletrónica e InformáticaThe 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.Atualmente, a natureza ubíqua de processadores multi-core faz da concorrência algo cada vez mais importante para utilização eficaz dos recursos. Mas a programação concorrente é complexa e dada a erros – antecipar a execução intercalada de processos e gerir o controlo de recursos partilhados é difícil; pode levar a comportamento incorreto, ou deadlocks em programas concorrentes. Assim, assegurar a correção de programas concorrentes é da maior importância. Tipos de sessão são uma disciplina de tipos para concorrência baseada na troca de mensagens que é capaz de dar fortes garantias de correção em tempo de com- pilação para programas concorrentes, oferecendo uma visão da comunicação em termos de protocolos-como-tipos. Utilizamos a interpretação de fórmulas da lógica linear intuici- onista como tipos de sessão, que serve de base para tipos de sessão lógicos que oferecem garantias mais fortes do que tipos de sessão simples. Neste trabalho implementamos uma linguagem funcional, com tipos de sessão (lógicos), juntamente com o seu type checker, e desenvolvemos um compilador para a dita linguagem que tem por alvo a linguagem Go. A linguagem apresenta as funcionalidades standard da programação funcional, combinadas com thread spawning e primitivas de concorrência baseadas em canais e tipificadas com tipos de sessão. A concorrência e valores funcionais são separados por uma interface tipo monad, ao estilo de Haskell. O processo de compilação recebe um programa, verifica o seu tipo para assegurar a ausência de deadlocks e erros de comunicação, e tradu-lo para código Go, utilizando a infraestrutura de canais e lightweight threads de Go. A tradução implica uma compensação da diferença entre os tipos de canais em Go e os tipos de sessão, que alcançamos através duma visão de tipos de sessão como máquinas de estados. Demons- tramos a expressividade da linguagem através duma série de exemplos, implementando idiomas de concorrência como map-reduce, entre outros. Realizamos uma avaliação de desempenho da implementação, experimentado definições diferentes e testando-a contra uma implementação nativa em Go, discutindo depois os resultados experimentais. Por fim, propomos várias abordagens para trabalho futuro, em termos de optimização do compilador e aumento da expressividade da linguagem.Toninho, BernardoRUNGeraldo, João Miguel Pereira do Cano Rico2023-03-24T11:46:23Z2022-112022-11-01T00:00:00Zinfo:eu-repo/semantics/publishedVersioninfo:eu-repo/semantics/masterThesisapplication/pdfhttp://hdl.handle.net/10362/151153enginfo:eu-repo/semantics/openAccessreponame:Repositórios Científicos de Acesso Aberto de Portugal (RCAAP)instname:FCCN, serviços digitais da FCT – Fundação para a Ciência e a Tecnologiainstacron:RCAAP2024-05-22T18:10:31Zoai:run.unl.pt:10362/151153Portal AgregadorONGhttps://www.rcaap.pt/oai/openaireinfo@rcaap.ptopendoar:https://opendoar.ac.uk/repository/71602025-05-28T17:40:58.964574Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) - FCCN, serviços digitais da FCT – Fundação para a Ciência e a Tecnologiafalse |
dc.title.none.fl_str_mv |
Making Session Types Go |
title |
Making Session Types Go |
spellingShingle |
Making Session Types Go Geraldo, João Miguel Pereira do Cano Rico Concurrency Session Types Logical Session Types Compilation Go Functional Language Domínio/Área Científica::Engenharia e Tecnologia::Engenharia Eletrotécnica, Eletrónica e Informática |
title_short |
Making Session Types Go |
title_full |
Making Session Types Go |
title_fullStr |
Making Session Types Go |
title_full_unstemmed |
Making Session Types Go |
title_sort |
Making Session Types Go |
author |
Geraldo, João Miguel Pereira do Cano Rico |
author_facet |
Geraldo, João Miguel Pereira do Cano Rico |
author_role |
author |
dc.contributor.none.fl_str_mv |
Toninho, Bernardo RUN |
dc.contributor.author.fl_str_mv |
Geraldo, João Miguel Pereira do Cano Rico |
dc.subject.por.fl_str_mv |
Concurrency Session Types Logical Session Types Compilation Go Functional Language Domínio/Área Científica::Engenharia e Tecnologia::Engenharia Eletrotécnica, Eletrónica e Informática |
topic |
Concurrency Session Types Logical Session Types Compilation Go Functional Language Domínio/Área Científica::Engenharia e Tecnologia::Engenharia Eletrotécnica, Eletrónica e Informática |
description |
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. |
publishDate |
2022 |
dc.date.none.fl_str_mv |
2022-11 2022-11-01T00:00:00Z 2023-03-24T11:46:23Z |
dc.type.status.fl_str_mv |
info:eu-repo/semantics/publishedVersion |
dc.type.driver.fl_str_mv |
info:eu-repo/semantics/masterThesis |
format |
masterThesis |
status_str |
publishedVersion |
dc.identifier.uri.fl_str_mv |
http://hdl.handle.net/10362/151153 |
url |
http://hdl.handle.net/10362/151153 |
dc.language.iso.fl_str_mv |
eng |
language |
eng |
dc.rights.driver.fl_str_mv |
info:eu-repo/semantics/openAccess |
eu_rights_str_mv |
openAccess |
dc.format.none.fl_str_mv |
application/pdf |
dc.source.none.fl_str_mv |
reponame:Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) instname:FCCN, serviços digitais da FCT – Fundação para a Ciência e a Tecnologia instacron:RCAAP |
instname_str |
FCCN, serviços digitais da FCT – Fundação para a Ciência e a Tecnologia |
instacron_str |
RCAAP |
institution |
RCAAP |
reponame_str |
Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) |
collection |
Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) |
repository.name.fl_str_mv |
Repositórios Científicos de Acesso Aberto de Portugal (RCAAP) - FCCN, serviços digitais da FCT – Fundação para a Ciência e a Tecnologia |
repository.mail.fl_str_mv |
info@rcaap.pt |
_version_ |
1833596886496313344 |