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 employ 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 reduce performance impact. A codesigned runtime system manages this 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 compaction, reducing memory usage by up to 40% in Redis.
翻译:非托管语言中无法重定位对象带来了诸多问题。其中影响最大的是内存碎片化,这一问题长期困扰着数据库和Web服务器等应用程序。由于堆对象在非托管语言中通常无法移动,这些问题要么持续恶化,要么需要程序员付出巨大努力才能针对每个应用单独解决。相比之下,C#等托管语言通过基于堆对象移动的压缩式垃圾回收技术,能够有效解决碎片化问题。本研究通过引入句柄(handles)——一种允许堆对象移动的间接层级——弥合了非托管与托管语言之间的差距。句柄为非托管语言中原有未修改代码无缝引入托管语言的运行时功能打开了大门。我们描述了一种新型编译器与运行时系统ALASKA,它可作为malloc的直接替代品。无需任何程序员干预,ALASKA编译器即可将基于指针的代码转换为使用句柄,并通过优化降低性能影响。协同设计的运行时系统管理这一间接层级,并通过可扩展服务接口利用堆对象移动。我们考察了ALASKA在多领域大型基准测试和应用程序中的开销。为展示句柄的强大能力与可扩展性,我们利用ALASKA通过压缩消除堆碎片化,使Redis的内存使用量最高降低40%。