Abstract
Rust is a popular systems language focused on performance and reliability, with an emphasis on providing “fearless concurrency”. Message passing has become a widely-used pattern by Rust developers although the potential for communication errors leaves developing safe and concurrent applications an unsolved challenge. In this ongoing work, we use multiparty session types to provide safety guarantees such as deadlock-freedom by coordinating message-passing processes. In contrast to previous contributions [20,21,22], our implementation targets asynchronous applications using
/
code in Rust. Specifically, we incorporate asynchronous subtyping theory, which allows program optimisation through reordering input and output actions. We evaluate our ideas by developing several representative use cases from the literature and by taking microbenchmarks. We discuss our plans to support full API generation integrating asynchronous optimisations.
Keywords
- Rust
- Asynchronous communication
- Deadlock-freedom
- Session types
This is a preview of subscription content, access via your institution.
Buying options






Notes
- 1.
We use session type syntax [31] where ! and ? denote send and receive respectively.
References
Introduction to Protocol Engineering. http://cs.uccs.edu/~cs522/pe/pe.htm. Accessed 19 Feb 2021
Rumpsteak. https://github.com/zakcutner/rumpsteak
\(\nu \)Scr. https://github.com/nuscr/nuscr
Ancona, D., et al.: Behavioral types in programming languages. Found. Trends Program. Lang. 3(2–3), 95–230 (2016)
Bouajjani, A., Enea, C., Ji, K., Qadeer, S.: On the completeness of verifying message passing programs under bounded asynchrony. In: Chockler, H., Weissenbacher, G. (eds.) CAV 2018. LNCS, vol. 10982, pp. 372–391. Springer, Cham (2018). https://doi.org/10.1007/978-3-319-96142-2_23
Bravetti, M., Carbone, M., Lange, J., Yoshida, N., Zavattaro, G.: A sound algorithm for asynchronous session subtyping. Leibniz Int. Proc. Inform. 140, 38:1–38:16 (2019)
Bravetti, M., Carbone, M., Zavattaro, G.: Undecidability of asynchronous session subtyping. Inf. Comput. 256, 300–320 (2017)
Bravetti, M., Carbone, M., Zavattaro, G.: On the boundary between decidability and undecidability of asynchronous session subtyping. Theoret. Comput. Sci. 722, 19–51 (2018)
Castro, D., Hu, R., Jongmans, S.S., Ng, N., Yoshida, N.: Distributed Programming Using Role-parametric Session Types in Go: Statically-typed Endpoint APIs for Dynamically-instantiated Communication Structures. Proceedings of the ACM on Programming Languages 3(POPL), 29:1–29:30 (2019)
Castro-Perez, D., Yoshida, N.: CAMP: cost-aware multiparty session protocol. Proc. ACM Program. Lang. 4(OOPSLA), 1–30 (2020)
Cutner, Z., Yoshida, N.: Safe session-based asynchronous coordination in rust. https://github.com/zakcutner/coordination-2021
Donovan, R.: Why the developers who use rust love it so much (2020). https://stackoverflow.blog/2020/06/05/why-the-developers-who-use-rust-love-it-so-much/. Accessed 31 Jan 2021
Gay, S., Ravara, A.: Behavioural Types: From Theory to Tools. River Publisher (2017)
Ghilezan, S., Pantovic, J., Prokic, I., Scalas, A., Yoshida, N.: Precise subtyping for asynchronous multiparty sessions. In: Proceedings of the ACM on Programming Languages, POPL, vol. 5, pp. 16:1–16:28. ACM (2021)
Heisler, B.: Criterion.rs. https://github.com/bheisler/criterion.rs
Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. In: Proceedings of the ACM on Programming Languages, POPL, pp. 273–284. ACM (2008)
Honda, K., Yoshida, N., Carbone, M.: Multiparty asynchronous session types. JACM 63, 1–67 (2016)
Hu, R., Yoshida, N.: Hybrid session verification through endpoint API generation. In: Stevens, P., Wąsowski, A. (eds.) FASE 2016. LNCS, vol. 9633, pp. 401–418. Springer, Heidelberg (2016). https://doi.org/10.1007/978-3-662-49665-7_24
Huang, H., Pillai, P., Shin, K.G.: Improving wait-free algorithms for interprocess communication in embedded real-time systems. In: 2002 USENIX Annual Technical Conference (USENIX ATC 02). USENIX Association (2002)
Jespersen, T.B.L., Munksgaard, P., Larsen, K.F.: Session types for rust. In: Proceedings of the 11th ACM SIGPLAN Workshop on Generic Programming, WGP, pp. 13–22. ACM (2015)
Kokke, W.: Rusty variation: deadlock-free sessions with failure in rust. Electron. Proc. Theoret. Comput. Sci. 304, 48–60 (2019)
Lagaillardie, N., Neykova, R., Yoshida, N.: Implementing multiparty session types in rust. In: Bliudze, S., Bocchi, L. (eds.) COORDINATION 2020. LNCS, vol. 12134, pp. 127–136. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-50029-0_8
Lange, J., Yoshida, N.: On the undecidability of asynchronous session subtyping. In: Esparza, J., Murawski, A.S. (eds.) FoSSaCS 2017. LNCS, vol. 10203, pp. 441–457. Springer, Heidelberg (2017). https://doi.org/10.1007/978-3-662-54458-7_26
Lange, J., Yoshida, N.: Verifying asynchronous interactions via communicating session automata. In: Dillig, I., Tasiran, S. (eds.) CAV 2019. LNCS, vol. 11561, pp. 97–117. Springer, Cham (2019). https://doi.org/10.1007/978-3-030-25540-4_6
Miu, A., Ferreira, F., Yoshida, N., Zhou, F.: Communication-safe web programming in typescript with routed multiparty session types. In: Proceedings of the 30th ACM SIGPLAN International Conference on Compiler Construction, CC, pp. 94–106. ACM (2021)
Neykova, R., Hu, R., Yoshida, N., Abdeljallal, F.: A session type provider: compile-time API generation of distributed protocols with refinements in F#. In: 27th International Conference on Compiler Construction, CC, pp. 128–138. ACM (2018)
Scribble Authors: Scribble: Describing Multi Party Protocols (2015). http://www.scribble.org/
The Rust Project Developers: Procedural Macros. https://doc.rust-lang.org/reference/procedural-macros.html
The Rust Survey Team: Rust Survey 2020 Results (2020). https://blog.rust-lang.org/2020/12/16/rust-survey-2020.html. Accessed 31 Jan 2021
Tokio Contributors: Tokio. https://github.com/tokio-rs/tokio
Yoshida, N., Gheri, L.: A very gentle introduction to multiparty session types. In: Hung, D.V., D’Souza, M. (eds.) ICDCIT 2020. LNCS, vol. 11969, pp. 73–93. Springer, Cham (2020). https://doi.org/10.1007/978-3-030-36987-3_5
Yoshida, N., Hu, R., Neykova, R., Ng, N.: The scribble protocol language. In: Abadi, M., Lluch Lafuente, A. (eds.) TGC 2013. LNCS, vol. 8358, pp. 22–41. Springer, Cham (2014). https://doi.org/10.1007/978-3-319-05119-2_3
Zhou, F., Ferreira, F., Hu, R., Neykova, R., Yoshida, N.: Statically verified refinements for multiparty protocols. Proc. ACM Program. Lang. 4(OOPSLA) (2020)
Acknowledgements
We thank Nicolas Lagaillardie and Fangyi Zhou for their helpful comments and suggestions. The work is supported by EPSRC, grants EP/T006544/1, EP/K011715/1, EP/K034413/1, EP/L00058X/1, EP/N027833/1, EP/N028201/1, EP/T014709/1, and EP/V000462/1 and by NCSS/EPSRC VeTSS.
Author information
Authors and Affiliations
Corresponding author
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 2021 IFIP International Federation for Information Processing
About this paper
Cite this paper
Cutner, Z., Yoshida, N. (2021). Safe Session-Based Asynchronous Coordination in Rust. In: Damiani, F., Dardha, O. (eds) Coordination Models and Languages. COORDINATION 2021. Lecture Notes in Computer Science(), vol 12717. Springer, Cham. https://doi.org/10.1007/978-3-030-78142-2_5
Download citation
DOI: https://doi.org/10.1007/978-3-030-78142-2_5
Published:
Publisher Name: Springer, Cham
Print ISBN: 978-3-030-78141-5
Online ISBN: 978-3-030-78142-2
eBook Packages: Computer ScienceComputer Science (R0)
-
Published in cooperation with
http://www.ifip.org/