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

📅 2025-02-15
🏛️ The Art, Science, and Engineering of Programming
📈 Citations: 0
Influential: 0
📄 PDF
🤖 AI Summary
This paper addresses excessive memory overhead of data structures in Java applications. We propose an automated optimization method that synergistically combines runtime profiling with ahead-of-time (AOT) compilation. By collecting fine-grained, allocation-site-level usage characteristics—such as element count, access patterns, and object lifetime—we construct lightweight behavioral profiles. These profiles drive automatic, end-to-end replacement of standard library data structures with memory-efficient alternatives during GraalVM Native Image AOT compilation—requiring no manual intervention. Our key contribution is the deep integration of dynamic configuration analysis and static compilation, enabling precise, context-aware injection of customized, memory-optimized implementations. Evaluation across multiple benchmarks demonstrates up to 13.85% reduction in memory footprint; average reductions are 1.63% on standard benchmarks and 2.94% on microservice workloads.

Technology Category

Application Category

📝 Abstract
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.
Problem

Research questions and friction points this paper is trying to address.

Automated replacement of data structures to optimize memory usage.
Profiling-based approach to customize data structures in Java applications.
Demonstrates memory reduction in benchmarks and microservice-based applications.
Innovation

Methods, ideas, or system contributions that make the work stand out.

Automated profiling for data structure optimization
Customized data structure replacement for memory efficiency
Integration with GraalVM Native Image compiler
🔎 Similar Papers
No similar papers found.
L
Lukas Makor
Institute for System Software, Johannes Kepler University Linz, Austria
S
Sebastian Kloibhofer
Institute for System Software, Johannes Kepler University Linz, Austria
Peter Hofer
Peter Hofer
Oracle Labs
David Leopoldseder
David Leopoldseder
Oracle Labs
GraalVMCompilersOptimizations
Hanspeter Mössenböck
Hanspeter Mössenböck
Professor of Computer Science, Johannes Kepler University Linz
Programming LanguagesCompilersVirtual MachinesSystem Software