arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2205.09655cs.PLcs.DS
收藏

Primrose:按属性选择容器数据类型

Primrose: Selecting Container Data Types by Their Properties

Xueying Qin, Liam O'Connor, Michel Steuwer

摘要:

内容:容器数据类型在计算机编程中无处不在,使开发人员能够使用易于使用的编程接口有效地存储和处理数据集合。许多程序设计语言基于提供不同功能和性能特征的数据结构在其标准库中提供各种容器实现。咨询电话:为应用程序选择“最佳”容器并不总是那么简单,因为性能特征在不同的场景中可能会发生巨大变化,而且实际性能并不总是与理论复杂性相关。方法:我们提出了Primrose,一个与语言无关的工具,用于从一组满足应用程序开发人员给出的 * 属性 * 的容器数据类型中选择性能最佳的有效容器实现。Primrose会自动选择一组有效的容器实现,由容器库开发人员编写的 * 库规范 * 满足指定的属性。最后,Primrose根据它们的运行时性能对有效的库实现进行排名。知识:使用Primrose,应用程序开发人员可以将容器的预期行为指定为具有 * 语义属性 * 的类型细化,例如,如果容器应该只包含唯一的值(例如“set”),或者应该满足“stack”的LIFO属性。语义属性很好地补充了 * 语法属性 *(即,traits,接口或类型类),一起允许开发人员指定容器的编程接口 * 和 * 行为,而无需提交具体的实现。接地:我们提出了Primrose的原型实现,它预处理带注释的Rust代码,选择有效的容器实现并根据它们的性能对其进行排名。Primrose的设计是与语言无关的,并且很容易集成到其他支持容器数据类型和trait、接口或类型类的程序设计语言中。我们的实现将属性和库规范编码到Rosette中的验证条件中,Rosette是SMT求解器的接口,它确定了有效容器实现的集合。我们通过指定几个容器实现来评估Primrose,并测量使用求解器为各种属性组合选择有效实现所需的时间。我们通过基于属性的测试自动验证容器实现是否符合其库规范。重要性:这项工作提供了一种新的方法,使抽象建模和规范的容器类型直接进入程序员的工作流程。应用程序员现在可以在规范级别上工作,而不是选择具体的容器实现,只需说明他们需要的容器类型的行为,并且可以自动选择最佳实现。

英文摘要:

Context: Container data types are ubiquitous in computer programming, enabling developers to efficiently store and process collections of data with an easy-to-use programming interface. Many programming languages offer a variety of container implementations in their standard libraries based on data structures offering different capabilities and performance characteristics. Inquiry: Choosing the *best* container for an application is not always straightforward, as performance characteristics can change drastically in different scenarios, and as real-world performance is not always correlated to theoretical complexity. Approach: We present Primrose, a language-agnostic tool for selecting the best performing valid container implementation from a set of container data types that satisfy *properties* given by application developers. Primrose automatically selects the set of valid container implementations for which the *library specifications*, written by the developers of container libraries, satisfies the specified properties. Finally, Primrose ranks the valid library implementations based on their runtime performance. Knowledge: With Primrose, application developers can specify the expected behaviour of a container as a type refinement with *semantic properties*, e.g., if the container should only contain unique values (such as a `set`) or should satisfy the LIFO property of a `stack`. Semantic properties nicely complement *syntactic properties* (i.e., traits, interfaces, or type classes), together allowing developers to specify a container's programming interface *and* behaviour without committing to a concrete implementation. Grounding: We present our prototype implementation of Primrose that preprocesses annotated Rust code, selects valid container implementations and ranks them on their performance. The design of Primrose is, however, language-agnostic, and is easy to integrate into other programming languages that support container data types and traits, interfaces, or type classes. Our implementation encodes properties and library specifications into verification conditions in Rosette, an interface for SMT solvers, which determines the set of valid container implementations. We evaluate Primrose by specifying several container implementations, and measuring the time taken to select valid implementations for various combinations of properties with the solver. We automatically validate that container implementations conform to their library specifications via property-based testing. Importance: This work provides a novel approach to bring abstract modelling and specification of container types directly into the programmer's workflow. Instead of selecting concrete container implementations, application programmers can now work on the level of specification, merely stating the behaviours they require from their container types, and the best implementation can be selected automatically.

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

↑