一句话:提出 Alaska 编译器与运行时,用句柄为不可移动的非托管堆对象增加间接层,实现无需修改代码的压缩式内存管理。
非托管语言通常无法移动堆对象,导致内存碎片长期困扰数据库、Web 服务器等应用,而托管语言依靠压缩式 GC 解决该问题。本文引入句柄这一间接层,使非托管语言中的堆对象也可被移动,从而在既有未修改代码中直接使用托管运行时特性。作者实现 Alaska:作为 malloc 的 drop-in 替代,编译器自动把基于指针的代码转换为使用句柄,并通过优化降低开销;配套运行时管理该间接层,并通过可扩展服务接口利用对象移动。评估覆盖多个领域的大型基准与应用,测量开销,并用 Alaska 对 Redis 堆去碎片化,最高减少 40% 内存占用。
The inability to relocate objects in unmanaged languages brings with it a menagerie of problems. Perhaps the most impactful is memory fragmentation, which has long plagued applications such as databases and web servers. These issues either fester or require Herculean programmer effort to address on a per-application basis because, in general, heap objects cannot be moved in unmanaged languages. In contrast, managed languages like C# cleanly address fragmentation through the use of compacting garbage collection techniques built upon heap object movement. In this work, we bridge this gap between unmanaged and managed languages through the use of handles, a level of indirection allowing heap object movement. Handles open the door to seamlessly employing runtime features from managed languages in existing, unmodified code written in unmanaged languages. We describe a new compiler and runtime system, Alaska, that acts as a drop-in replacement for malloc. Without any programmer effort, the Alaska compiler transforms pointer-based code to utilize handles, with optimizations to minimize performance impact. A codesigned runtime system manages this new level of indirection and exploits heap object movement via an extensible service interface. We investigate the overheads of Alaska on large benchmarks and applications spanning multiple domains. To show the power and extensibility of handles, we use Alaska to eliminate fragmentation on the heap through defragmentation, reducing memory usage by up to 40% in Redis.