节点文献
用代码缓存复用技术提升Android即时编译器效率
Using Code Caching and Reusing to Improve Efficiency of Android JIT Compiler
【作者】 周波;
【导师】 臧斌宇;
【作者基本信息】 复旦大学 , 计算机软件与理论, 2012, 硕士
【摘要】 运行时系统是执行计算机程序的基本环境,如何提升其执行效率是计算机学科的研究热点与难点之一。Java虚拟机作为一种重要的运行时系统,因易于扩展、便于跟踪程序执行和程序移植等优点而被广泛研究。近年来,借助即时编译、并行执行等方法,桌面平台与服务器平台的虚拟机执行效率获得了很大提升。然而,对嵌入式平台虚拟机而言,受硬件资源限制,传统性能优化方法面临诸多挑战,如何提升其执行效率有待进一步研究。尤其是随着Android系统的流行,嵌入式Java虚拟机的性能问题得到日益关注,开展针对嵌入式平台虚拟机性能优化的研究变得更加迫切。通过对代码进行动态编译,即时编译技术被广泛应用于运行时系统进行性能优化。然而此类编译技术需要比较大的运行时开销,并不能直接用于嵌入式平台虚拟机。即时编译系统的运行时开销来自两个方面:检测延时和编译延时。目前,降低Java虚拟机即时编译系统开销的方法大多面向桌面和服务器平台,针对嵌入式Java虚拟机的方案仍是空白。本文针对这一技术空白,提出用轻量级的代码缓存复用技术来消除检测延时、降低编译延时从而降低嵌入式Java即时编译系统的运行时开销。本文在Android的运行时环境Dalvik基础上,设计实现了代码缓存复用框架CCARF(Code Caching And Reusing Framework)。通过在运行时复用先前缓存的可执行代码,CCARF有效地降低了编译延时,省去了对方法的热度检测过程,消除了检测延时。CCARF的核心是针对Android的位置无关代码的设计和缓存代码的管理与复用。它致力于提供一个实际、有效、轻量级的代码缓存与复用解决方案。CCARF的主要工作和贡献如下:1.探索了Java虚拟机生成的可执行代码中的位置相关性,并以Dalvik为例,分析总结了这些相关性对位置无关代码和缓存复用技术的影响。2.针对可执行代码中不同种类的位置依赖,分别提出了消除依赖的算法,并实现了相应的代码生成器。其中的引用按需解析和即时解析技术,取代了传统的基于符号表和链接器的解析技术,尤其适合嵌入式平台。3.探讨了不同的代码复用策略对降低嵌入式Java虚拟机编译器延时的影响,并设计实现了高效的位置无关代码管理器,包括设计可执行代码的存储格式,缓存文件加载策略以及已缓存文件检测算法等。4.以SPECjvm98测试套件为基础设计了较完整的实验,并从性能提升、代码膨胀和缓存空间大小三方面对CCARF做出了评测。结果表明,CCARF在可执行代码平均膨胀率6%的情况下,能提升SPECjvm98测试程序平均性能约11.7%。
【Abstract】 How to improve the efficiency of runtime system is one of the hot and difficult problems being worked on by computer researchers. As one typical runtime system, Java virtual machine (JVM) has been paid much attention for its good extensibility and portability. Recently, with the development of JIT compilation and parallel compilation techniques, JVM gains good improvement in its efficiency of program execution on PC and server platforms. However, those techniques bring little help for embedded JVMs due to the limitations of embedded systems. Finding methods to improve execution efficiency of Embedded JVMs becomes more and more important especially when Android becomes prevalent and begins to rock the world.JIT compilation technique is widely used to improve efficiency of JVMs. However, this method cannot be directly used on embedded JVMs as its high overhead. JIT compilers must try to reduce their detection latency and compilation latency. There are several solutions to reduce these latencies, but most are designed for PC and server platforms. For embedded JVMs, it requires new solutions and more research.This paper employs code caching and reusing technique to bring down overhead of JIT compilation system. On Dalvik, the runtime system of Android, we design and implement CCARF (Code Caching And Reusing Framework), which saves compiler-generated code to files and reduces compilation latency by reusing those files properly. With the reduction of compilation latency, method detection process is omitted and thus detection latency is eliminated. The core of CCARF is the design, management and reusing of position-independent code for Dalvik. It intends to make a real-world, effective and lightweight solution for caching and reusing executable code.This paper has the following contributions:1. It explored position dependencies in executable code generated by JVM JIT compilers, and analyzed their influence on position-independent code generation and code caching and reusing technique.2. It proposed new algorithms to eliminate different kinds of position dependencies in executable code, and implemented those algorithms in compiler code generator. Lightweight on-demand resolution and just-in-time resolution techniques are proposed to replace the traditional symbol table and dynamic linker based method.3. It analyzed and summarized effectiveness of different reusing policies on reducing latencies of JIT compilers, and implemented position-independent code manager to effectively utilize cached code.4. It designed experiments based on sophisticated SPECjvm98benchmarks, and evaluated CCARF from aspects of performance improvement, code expansion and cache size. Results showed that CCARF improved the performance of benchmarks by11.7%on average with a code expansion rate at6%.
【Key words】 Code Caching; Code Reusing; JIT Compilation; Compilation Latency; Detection Latency;