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

自动配置引导的数据结构替换以减少内存分配

Automated Profile-Guided Replacement of Data Structures to Reduce Memory Allocation

Lukas Makor, Sebastian Kloibhofer, Peter Hofer, David Leopoldseder, Hanspeter Mössenböck

AI总结:

本文提出一种自动替换Java应用中数据结构的方法,通过性能分析定制分配版本,集成于GraalVM Native Image,显著降低内存使用,标准基准平均降1.63%,微服务基准降2.94%。

摘要:

数据结构是大多数现代编程语言的基石。无论是通过单独的库提供、内置于语言规范中,还是作为语言标准库的一部分——诸如列表、映射、集合或数组等数据结构为程序员提供了处理数据的大量工具。此外,每种数据结构通常都带有多种实现,这些实现侧重于可扩展性、内存效率、性能、线程安全性或类似方面。对于特定用例选择*正确*的数据结构可能是困难的,甚至是不可能的,如果该数据结构是用户无法控制的框架的一部分。这通常需要对程序有深入的了解,特别是对所讨论的数据结构的使用情况。然而,开发者通常无法事先获得此类程序信息。因此,寻找一种更自动化的方式来优化数据结构是有意义的。我们提出了一种自动替换Java应用程序中数据结构的方法。我们使用性能分析来确定关于数据结构及其使用的分配站点特定指标,然后自动将其分配替换为定制版本,重点关注内存效率。我们的方法集成到了GraalVM Native Image中,这是一个用于Java应用程序的前期编译器。通过分析生成的数据结构配置文件,我们展示了标准基准测试和基于微服务的应用程序如何使用数据结构,并演示了定制数据结构对应用程序内存使用的影响。我们在标准和基于微服务的基准测试上进行了评估,在大量使用数据结构的基准测试中,内存使用量减少了高达13.85%。虽然其他基准测试仅受到轻微影响,但我们仍然在标准基准测试中将平均内存使用量减少了1.63%,在基于微服务的基准测试中减少了2.94%。我们认为我们的工作表明,选择合适的数据结构可以减少应用程序的内存使用。虽然我们承认我们的方法并非对所有类型的工作负载都有益,但我们的工作仍然展示了如何使用自动化性能分析和替换来普遍优化数据结构。因此,我们认为我们的工作可以为未来数据结构的优化铺平道路。

英文摘要:

Data structures are a cornerstone of most modern programming languages. Whether they are provided via separate libraries, built into the language specification, or as part of the language's standard library -- data structures such as lists, maps, sets, or arrays provide programmers with a large repertoire of tools to deal with data. Moreover, each kind of data structure typically comes with a variety of implementations that focus on scalability, memory efficiency, performance, thread-safety, or similar aspects. Choosing the *right* data structure for a particular use case can be difficult or even impossible if the data structure is part of a framework over which the user has no control. It typically requires in-depth knowledge about the program and, in particular, about the usage of the data structure in question. However, it is usually not feasible for developers to obtain such information about programs in advance. Hence, it makes sense to look for a more automated way for optimizing data structures. We present an approach to automatically replace data structures in Java applications. We use profiling to determine allocation-site-specific metrics about data structures and their usages, and then automatically replace their allocations with customized versions, focusing on memory efficiency. Our approach is integrated into GraalVM Native Image, an Ahead-of-Time compiler for Java applications. By analyzing the generated data structure profiles, we show how standard benchmarks and microservice-based applications use data structures and demonstrate the impact of customized data structures on the memory usage of applications. We conducted an evaluation on standard and microservice-based benchmarks, in which the memory usage was reduced by up to 13.85 % in benchmarks that make heavy use of data structures. While others are only slightly affected, we could still reduce the average memory usage by 1.63 % in standard benchmarks and by 2.94 % in microservice-based benchmarks. We argue that our work demonstrates that choosing appropriate data structures can reduce the memory usage of applications. While acknowledge that our approach does not provide benefits for all kinds of workloads, our work nevertheless shows how automated profiling and replacement can be used to optimize data structures in general. Hence, we argue that our work could pave the way for future optimizations of data structures.

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

↑