arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2303.03983cs.PL
收藏

真实世界中的编排式编程:全双工异步性与互操作性

Real-World Choreographic Programming: Full-Duplex Asynchrony and Interoperability

Lovro Lugović, Fabrizio Montesi

AI总结:

本文首次用编排式编程语言Choral实现IRC协议,验证了该范式在真实世界协议中的可行性,并通过子类型化扩展解决选择通信的静态检测问题,实现与第三方软件的互操作性。

摘要:

在编排式编程范式中,分布式系统的整体行为是从全局视角以编排(choreography)的形式编码的。随后,该编排可以被自动投影(编译)为每个参与者的正确实现。这一范式之所以引人注目,是因为它免除了程序员手动编写参与者所执行的独立发送和接收操作,从而简化了开发并避免了通信不匹配。\n然而,编排式编程在真实世界中的适用性在很大程度上仍未得到探索。原因有二。首先,尽管已有若干编排式编程语言的提案,但其中没有一种语言被用于实现一个现实的、广泛使用的协议。因此,缺乏关于真实编排式程序如何构建以及理论模型中探索的不同特性的相关性的经验。其次,迄今为止所展示的编排式编程应用具有侵入性,即每个参与者必须精确使用从编排中投影出的代码。这阻止了将编排生成的代码与某些参与者的现有第三方实现一起使用,而这种做法对于测试非常有益,甚至可能成为一项要求。\n本文解决了这两个问题。具体而言,我们进行了首次使用编排式编程开发一个广泛使用的现实世界协议:互联网中继聊天(IRC)客户端-服务器协议。该开发基于Choral,一种面向对象的高阶编排式编程语言(编排可以在编排上参数化并携带状态)。\n我们发现Choral的两个特性对我们的实现至关重要:高阶编排用于建模由于IRC的异步性而产生的复杂交互模式,而用户可定义的通信语义对于实现与第三方实现的互操作性至关重要。在此过程中,我们还发现了一个缺失的部分:静态检测关于替代分布式行为的选择是否通过消息类型被适当传达的能力,为此我们基于子类型化扩展了Choral编译器,提供了一种优雅的解决方案。\n我们使用Choral对IRC的实现可以说是编排式编程的一个里程碑,因为这是该范式能够忠实编码“野外”发现的协议的首个经验证据。我们观察到,与编写单独的发送和接收操作的传统方法相比,编排式方法降低了我们程序的交互复杂性。为了检查我们的实现确实能与第三方软件互操作,我们针对IRC的公开一致性测试以及一些最流行的IRC客户端和服务器软件对其进行了测试。我们还通过执行性能测试来评估我们实现的性能和可扩展性。\n我们的经验表明,即使编排式编程仍处于早期阶段,它已经可以应用于现实环境。

英文摘要:

In the paradigm of choreographic programming, the overall behaviour of a distributed system is coded as a choreography from a global viewpoint. The choreography can then be automatically projected (compiled) to a correct implementation for each participant. This paradigm is interesting because it relieves the programmer from manually writing the separate send and receive actions performed by participants, which simplifies development and avoids communication mismatches. However, the applicability of choreographic programming in the real world remains largely unexplored. The reason is twofold. First, while there have been several proposals of choreographic programming languages, none of these languages have been used to implement a realistic, widely-used protocol. Thus there is a lack of experience on how realistic choreographic programs are structured and on the relevance of the different features explored in theoretical models. Second, applications of choreographic programming shown so far are intrusive, in the sense that each participant must use exactly the code projected from the choreography. This prevents using the code generated from choreographies with existing third-party implementations of some participants, something that is very beneficial for testing or might even come as a requirement. This paper addresses both problems. In particular, we carry out the first development in choreographic programming of a widespread real-world protocol: the Internet Relay Chat (IRC) client--server protocol. The development is based on Choral, an object-oriented higher-order choreographic programming language (choreographies can be parametric on choreographies and carry state). We find that two of Choral's features are key to our implementation: higher-order choreographies are used for modelling the complex interaction patterns that arise due to IRC's asynchronous nature, while user-definable communication semantics are relevant for achieving interoperability with third-party implementations. In the process we also discover a missing piece: the capability of statically detecting that choices on alternative distributed behaviours are appropriately communicated by means of message types, for which we extend the Choral compiler with an elegant solution based on subtyping. Our Choral implementation of IRC arguably represents a milestone for choreographic programming, since it is the first empirical evidence that the paradigm can be used to faithfully codify protocols found `in the wild'. We observe that the choreographic approach reduces the interaction complexity of our program, compared to the traditional approach of writing separate send and receive actions. To check that our implementation is indeed interoperable with third-party software, we test it against publicly available conformance tests for IRC and some of the most popular IRC client and server software. We also evaluate the performance and scalability of our implementation by performing performance tests. Our experience shows that even if choreographic programming is still in its early life, it can already be applied to a realistic setting.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑