arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2405.00038cs.PLcs.OS
收藏

掌控非托管内存

Getting a Handle on Unmanaged Memory

Nick Wanninger, Tommy McMichen, Simone Campanoni, Peter Dinda

AI总结:

本文提出编译器与运行时系统 ALASKA,通过句柄间接层使非托管语言中的堆对象可移动,从而以 malloc 直接替代品的方式实现压缩去碎片化,在 Redis 中降低内存使用达 40%。

摘要:

在非托管语言中无法重定位对象会带来一系列问题。其中影响最大的或许是内存碎片化,这一问题长期困扰着数据库和 Web 服务器等应用。这些问题要么持续恶化,要么需要程序员付出巨大努力针对每个应用逐一解决,因为一般而言,在非托管语言中堆对象无法被移动。相比之下,C# 等托管语言通过建立在堆对象移动基础上的压缩垃圾回收技术,能够干净利落地解决碎片化问题。在本工作中,我们通过使用句柄(handles)——一种允许堆对象移动的间接层——弥合了非托管语言与托管语言之间的这一差距。句柄为在现有的、未经修改的非托管语言代码中无缝运用托管语言的运行时特性打开了大门。我们描述了一个新的编译器与运行时系统 ALASKA,它可以作为 malloc 的直接替代品。无需任何程序员努力,ALASKA 编译器即可将基于指针的代码转换为利用句柄的代码,并通过优化来降低性能影响。一个协同设计的运行时系统管理这一间接层,并通过可扩展的服务接口利用堆对象移动能力。我们在跨多个领域的大型基准测试和应用上考察了 ALASKA 的开销。为了展示句柄的强大能力和可扩展性,我们使用 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 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.

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

↑