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

实践中的数组:JVM 上数组访问模式的实证研究

Arrays in Practice: An Empirical Study of Array Access Patterns on the JVM

Beatrice Åkerblom, Elias Castegren

AI总结:

本文通过对 JVM 上 Renaissance 基准程序动态插桩并追踪 38 亿余次数组访问,实证分析数组大小、类型、访问位置与模式,为运行时和编译器优化提供依据。

摘要:

数组是一种在广泛程序中使用的数据结构。其紧凑存储和常数时间随机访问使其非常高效,但任意索引使包含数组访问的代码分析变得复杂。此类分析对于边界检查消除等编译器优化非常重要。本工作的目标是更好地理解真实世界程序中数组的使用方式。尽管先前工作已应用静态分析来理解数组如何被访问和使用,我们采用动态方法。我们通过对程序进行插桩以记录所有数组访问,实证考察数组使用的各种特征,从而分析数组大小、元素类型、数组从何处被访问,以及数组访问序列在多大程度上形成可识别的模式。研究中的程序收集自 Renaissance 基准测试套件,全部运行在 Java Virtual Machine 上。我们说明了所考察数组表现出的特征,发现多数数组尺寸较小,仅被一两个类和单个线程访问。在各基准测试上平均而言,69.8% 的访问模式由简单遍历构成。大多数被插桩的类(超过 95%)根本不直接使用数组。这些结果来自追踪数据,覆盖跨 168,686 个类发生的 3,803,043,390 次数组访问。虽然我们的分析仅应用于 Renaissance 基准测试套件,但该方法可应用于任何运行在 Java Virtual Machine 上的程序。本研究以及更一般的方法可为未来运行时实现和编译器优化提供依据。

英文摘要:

The array is a data structure used in a wide range of programs. Its compact storage and constant time random access makes it highly efficient, but arbitrary indexing complicates the analysis of code containing array accesses. Such analyses are important for compiler optimisations such as bounds check elimination. The aim of this work is to gain a better understanding of how arrays are used in real-world programs. While previous work has applied static analyses to understand how arrays are accessed and used, we take a dynamic approach. We empirically examine various characteristics of array usage by instrumenting programs to log all array accesses, allowing for analysis of array sizes, element types, from where arrays are accessed and to which extent sequences of array accesses form recognizable patterns. The programs in the study were collected from the Renaissance benchmark suite, all running on the Java Virtual Machine. We account for characteristics displayed by the arrays investigated, finding that most arrays have a small size, are accessed by only one or two classes and by a single thread. On average over the benchmarks, 69.8% of the access patterns consist of uncomplicated traversals. Most of the instrumented classes (over 95%) do not use arrays directly at all. These results come from tracing data covering 3,803,043,390 array accesses made across 168,686 classes. While our analysis has only been applied to the Renaissance benchmark suite, the methodology can be applied to any program running on the Java Virtual Machine. This study, and the methodology in general, can inform future runtime implementations and compiler optimisations.

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

↑