Probabilistic energy profiler for statically typed JVM-based programming languages
Joel Nyholm, Wojciech Mostowski, Christoph Reichenbach 1. Halmstad University, Sweden2. Lund University, Sweden · 2025
Read Probabilistic energy profiler for statically typed JVM-based programming languages by Joel Nyholm, Wojciech Mostowski, Christoph Reichenbach 1. Halmstad University, Sweden2. Lund University, Sweden (2025) in the Tower of Babel, a free online library of public-domain works preserved in clean, searchable text. No sign-up. The full text is served as a plain-text file at a predictable URL, where text is present: https://antarctic-labs.com/tower-of-babel/arxiv-2512-02738.txt.
Introduction
Joel Nyholm, Wojciech Mostowski, and Christoph Reichenbach profile energy use down to single lines of code. Energy demand grows from phones to huge data centers, and developers need detail to fix waste. Older profilers blame whole programs or single functions, which is too coarse to act on.
Their probabilistic profiler targets statically typed JVM based languages, including Java. It estimates energy per source statement, with uncertainty stated openly. Line level feedback could help teams cut the energy cost of common software, a growing share of global electricity use. Line by line costs show staff the exact line that eats the watts, not just the app as a whole blob.
Catalog record
| CREATOR | Joel Nyholm, Wojciech Mostowski, Christoph Reichenbach 1. Halmstad University, Sweden2. Lund University, Sweden |
|---|---|
| YEAR | 2025 |
| COLLECTION | PAPERS |
| FORMAT | TXT |
| FILE SIZE | 56 KB |
| VERSION | 1.0 |
| LICENSE | http://creativecommons.org/licenses/by/4.0/ |
| RIGHTS | CC BY |
| SOURCE | arXiv |
Source: https://arxiv.org/abs/2512-02738
Browse the full library · About the Tower of Babel
Full text
The opening of the work, from the library's hosted text:
Probabilistic energy profiler for statically typed JVM-based programming languages Joel Nyholm, Wojciech Mostowski, Christoph Reichenbach 1. Halmstad University, Sweden2. Lund University, Sweden Abstract Abstract Energy consumption is a growing concern in several fields, from mobile devices to large data centers. Developers need detailed information on the energy consumption of their software to mitigate consumption issues. Previous approaches mainly have a broader focus, such as on specific functions or complete programs, instead of source code statements. Additionally, they primarily focus on estimating the CPU’s energy consumption with point estimates, thus disregarding other hardware components’ energy consumption and limiting their use for statistical reasoning and explainability. We have created a novel methodology to address the limitations of only measuring the CPU’s consumption and using point estimates, where we focus on predicting the energy usage of statically typed JVM-based programming languages, such as Java, Kotlin, or Scala. We measure the energy consumption of Bytecode patterns, the translation from a specific programming language’s source code statement to its Java Bytecode representation. With the energy measurements, we construct a statistical model. Unlike prior approaches based on frequentist statistics, we create our model via Bayesian statistics, which allows us to predict the expected energy consumption through a statistical distribution and analyze individual contributing factors. The model includes three factors we can obtain statically from the code: data size , data type , operation , and one factor about the hardware platform the code executes on: device . To validate our methodology, we implemented it for Java, focusing on Java’s Bytecode patterns, and evaluated its energy predictions on previously unseen programs. We observe that all four factors are significant, notably that two devices of the same model may significantly differ in energy consumption and that the operations and data types cause significant consumption differences. The experiments also show that the energy prediction of programs closely follows the program’s real energy consumption, further validating our approach. Our work presents a methodology (not a tool) to construct an energy model that future work, e.g., energy-aware program analysis or verification tools, can use as their energy estimations. 1 Introduction Energy efficiency is a concern in many areas, such as mobile software design and software in data centers. Understanding and reducing the energy consumption of even simple software systems is challenging, and modern language run-time systems with dynamic optimizations increase this challenge. Consider statically typed JVM-based programming languages such as Java, Scala, or Kotlin, which use a platform-independent intermediate representation, Java Bytecode, executed on a virtual machine. The software’s energy consumption depends on the compiler with its optimizations, the Java Virtual Machine (JVM), the garbage collector, the operating system, and the target hardware. To understand the energy impact of software design decisions, a software engineer would need knowledge that penetrates these abstraction layers and the details of the intended execution platform(s). Prior work has explored approaches for workload-based energy profiling, where developers run software with a specific workload in a specialized execution environment that measures energy consumption and estimates how much of the consumption can be attributed to individual subroutines or even lines of code [ 35 , 6 , 25 , 5 ] . In practice, workload-based energy profiling requires a custom hardware setup, which limits its suitability for everyday software engineering: while some hardware platforms expose hardware performance counters for energy use of specific components (e.g., the CPU), few are able to measure the platform’s total energy consumption. Predictive approaches for estimating energy consumption avoid this hardware-dependence and rely purely on an execution trace. For Android, Hao et al. propose such an approach, eCalc , which constructs a platform-specific instruction-level energy usage model with five energy cost functions for different operations, and predicts the energy usage of a given execution trace as the sum of the Bytecode instruction estimates [ 14 ] . Even though their model does not account for interactions across neighbouring instructions (caching, branch prediction, page tables) or more finely-grained programming language constructs, such as data types, Hao et al. report an error of less than 10% for predicting energy usage of execution traces for several Android benchmarks, albeit on Android 2.x (now obsolete) running on an early Intel Atom CPU (on a custom board made specifically for the study). Predictive approaches such as eCalc are thus appealing as a foundation for software tools that help developers understand the energy usage properties of their code. However, existing approaches only predict point estimates, such as the expected value (the mean over infinitely many runs), which is insufficient for rigorous statistical reasoning or explainability. These approaches are therefore insufficient for supporting software tools that compare the energy efficiency of two software systems with statistical confidence or estimate the likelihood of whether a system can run for a certain duration on a given battery charge. To address the limitation of approaches, such as eCalc that only considers the CPU’s energy consumption and predicts using point estimates, we propose a new methodology that uses Bayesian statistics to create an energy model that infers a device’s total energy consumption when executing statically typed JVM-based programming languages. We here use the term ’methodology’ in the sense of a technical procedure that addresses a specific technical challenge. In our case, systematically constructing statistically robust answers to technical questions that can then serve to answer research questions or to construct software tools. The model our methodology defines uses a quadruple F=(T,d) consisting of a triple T , extended by the element d . The quadruple explains all factors we model, where the triple explains the source code statement’s arguments, T=\left<o,t,s\right> that we can statically obtain from the code: o peration, data t ype, data s ize. The element d is the d evice and can be added if the execution platform is known. It is included for generalization for a specific device, since energy consumption can behave differently on different instances of the same hardware platform due to variations in its electrical components [ 13 , 31 , 32 ] . Our model, to our knowledge, is the first predictive energy model for software to explicitly account for the effect of hardware differences on energy consumption. However, the methodology can disregard this category if the software has multiple or no specific target devices. The model constructs a Gaussian distribution for each quadruple that describes a source code statement, whilst also grouping each quadruple element to describe their individual effects on energy consumption, i.e., the energy consumption effect for operations, data types, data sizes and devices. This model approach has several benefits, such as explaining energy effects of changing data types for a given algorithm. The methodology explicitly targets the worst-case energy consumption (WCEC) of these single code statements and uses the convolution of individual prediction distributions to obtain a prediction for the energy consumption of functions and entire programs. Distributions represent the WCEC because a single point estimate does not explain the possible consumption values that the worst-case scenario can adopt due to random variations in the energy, e.g., because of temperature (Johnson-Nyquist noise) or external interferences (electromagnetic interference). It also retains its statistical properties, such as presenting the mean, skewness, and mode, and enabling calculation of the entropy, cumulative distribution, and probability density