对打包数据的类型安全且可移植的支持
Type-safe and portable support for packed data
AI总结:
针对主流语言缺乏对打包数据支持的问题,提出Haskell库packed-data,利用元编程实现类型安全且可移植的打包数据构建与读取,遍历速度比未打包数据快高达60%,方法可推广至支持高阶类型的语言。
摘要:
当系统的各组件交换数据时,它们需要对数据进行序列化,以便通过网络发送。随后,接收方必须对数据进行反序列化,才能对其进行处理。这些步骤需要耗费时间,并对系统的整体性能产生影响。\n解决此问题的一种方法是使用打包数据,它在内存和网络之间具有统一的表示形式,从而无需任何编组步骤。此外,使用这种数据表示方法可以通过数据在内存中紧凑表示所带来的数据局部性来提升程序性能。遗憾的是,目前没有主流编程语言支持打包数据,无论是开箱即用还是通过编译器扩展。\n我们提出了 packed-data,这是一个 Haskell 库,允许以函数式风格类型安全地构建和读取打包数据。该库不依赖编译器修改,因此具有可移植性,并利用元编程使程序员能够轻松地打包自己的数据类型。\n我们评估了该库的可用性和性能,并得出结论:它允许遍历打包数据的速度比未打包数据快高达 60%。我们还反思了如何增强基于库的打包数据支持的性能。\n我们的实现方法是通用的,可以轻松应用于任何支持高阶类型的编程语言。
英文摘要:
When components of a system exchange data, they need to serialise the data so that it can be sent over the network. Then, the recipient has to deserialise the data in order to be able to process it. These steps take time and have an impact on the overall system's performance. A solution to this is to use packed data, which has a unified representation between the memory and the network, removing the need for any marshalling steps. Additionally, using this data representation can improve the program's performance thanks to the data locality enabled by the compact representation of the data in memory. Unfortunately, no mainstream programming languages support packed data, whether it's out-of-the-box or through a compiler extension. We present packed-data, a Haskell library that allows for type safe building and reading of packed data in a functional style. The library does not rely on compiler modifications, making it portable, and leverages meta-programming to allow programmers to pack their own data types effortlessly. We evaluate the usability and performance of the library, and conclude that it allows traversing packed data up to 60% faster than unpacked data. We also reflect on how to enhance the performance of library-based support for packed data. Our implementation approach is general and can easily be used with any programming languages that support higher-kinded types.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。