=Paper=
{{Paper
|id=Vol-3867/paper3
|storemode=property
|title=Green Computing for Erlang
|pdfUrl=https://ceur-ws.org/Vol-3867/paper3.pdf
|volume=Vol-3867
|authors=Gharbi Youssef,István Bozó,Melinda Tóth
|dblpUrl=https://dblp.org/rec/conf/raw2/GharbiBT24
}}
==Green Computing for Erlang==
Green computing for Erlang⋆
Gharbi Youssef, István Bozó and Melinda Tóth
ELTE, Eötvös Loránd University, Faculty of Informatics, Budapest, Hungary
Abstract
Energy efficiency means to achieve the same result with less energy consumption. By reducing energy consumption, companies can
potentially experience both cost savings and improved software performance. Erlang is heavily used in continuously operating server
applications therefore the energy used by Erlang applications are quite significant. Any change, any reduction of the consumption of
Erlang applications might have significant amount on the total energy used by the servers. This presents a measurement environment
for Windows to be able to analyse the energy usage behaviour of Erlang applications. We used this environment to analyse various
Erlang applications. We present our finding and compare the behaviour of the Erlang BEAM on Windows and Linux.
Keywords
energy consumption, Erlang, green computing, measurements
1. Introduction data structures increases. The following research questions
guide our investigation:
Energy consumption is a major concern in every aspect 1. Runtime Performance Trends: - What are the trends in
of our life. Being energy efficient is a crucial factor of the the runtime performance of Erlang/OTP when processing
modern manufacturing process [1]. This also covers the pro- increasingly larger data structures on both Windows and
duction of computer components. In addition to producing Linux?
hardware components effectively, we also require efficient 2. Energy Consumption Comparison: - How does the
computers. energy consumption of Erlang/OTP on Windows compare
Computer performance is mostly determined by two fac- to Linux as the size of input data structures increases?
tors. The hardware we employ and the applications we use Our objective is not to determine which operating sys-
on our computers. For decades, people have been designing tem is optimal, but rather to observe and analyze how Er-
and producing ever-more energy-conscious hardware, but it lang/OTP behaves and trends on each operating system
has only recently became common practice to write energy- under varying conditions. By addressing these questions,
efficient software. Computers are being employed in more we aim to provide a comprehensive analysis of Erlang/OTP’s
energy-critical systems as a result of their ubiquitous use performance and energy efficiency on different operating
and the Internet of Things (IoT). systems with increasing input sizes.
Since environmental consciousness is growing in popu- The rest of the paper is structured as follows. In Section 2
larity [2], it is important to create software that is energy we present the context of our work including details on
efficient. Cisco says that 90% of internet traffic goes through the original GreenErl framework and our investigations on
Erlang-controlled nodes [3]. With 5.07 billion internet users selecting a proper measurement environment for Windows.
in the world growing by half a million daily [4], today comes Section 3 explains how the Scaphandre-based measurement
the need to have efficient Erlang code patterns more than environment was built for Windows. Section 4 describes
ever. our measurements and the analysis of the result. Finally,
Our work aims to analyse the energy efficiency of Erlang Sections 5 and 6 presents related works and concludes the
applications by identifying language components that use paper.
less energy and to guide the developers to design and write
more energy-efficient code. In our previous work [5, 6, 7] we
created a toolchain to measure the energy consumption of 2. Background
Erlang language constructs and designed refactoring steps
to transform the code to make it more efficient. The Green- In this paper we would like to investigate the energy be-
Erl framework focused on Linux-based measurements and haviour of Erlang applications. Therefore in this section we
analysis. are summarising the main concepts and tools we rely on.
In this paper, we are presenting a framework 1 that is
applicable to measure the energy consumption of Erlang 2.1. Green computing
software running on a Windows operating system. We built
Green computing is a study and practice of efficient and eco-
the framework on top of Scaphandre [8] and integrated it
friendly computing resources [11]. It involves developing,
with the previous GreenErl framework [5, 9]. We repeated
designing, engineering, producing, using, and disposing of
the measurements from the previous studies [10], analysed
computing modules and devices to reduce environmental
the results and compared the main findings with the Linux-
hazards and pollution [12].
based results.
Green computing become increasingly important in re-
This study aims to investigate the trends and behavior
cent years [13] as the world becomes more aware of the
of Erlang/OTP on Windows and Linux as the size of input
impact of technology on the environment [1, 14] and the
3rd workshop on Resource AWareness of Systems and Society (RAW 2024) utilization of mobile applications, embedded systems, and
$ ikycue@inf.elte.hu (G. Youssef); bozoistvan@elte.hu (I. Bozó); data center-based services increases [15, 16]. One way green
tothmelinda@elte.hu (M. Tóth)
computing can be achieved is through energy-efficient com-
0009-0005-3183-0343 (G. Youssef); 0000-0001-5145-9688 (I. Bozó);
0000-0001-6300-7945 (M. Tóth) puting by designing computer systems that use less energy
© 2024 Copyright for this paper by its authors. Use permitted under Creative Commons License Attribu-
tion 4.0 International (CC BY 4.0).
while still providing the same level of performance [17, 18].
1
https://github.com/joegharbi/greenErl Energy-efficient computing can be achieved through various
CEUR
ceur-ws.org
Workshop ISSN 1613-0073
Proceedings
methods such as using low-power processors [19], optimiz- In Linux environments, RAPL is widely utilized for
ing software code [20], and using virtualization technol- energy-conscious tasks such as monitoring, profiling, and
ogy [21]. Another way green computing can be achieved improving the energy efficiency of software and hardware.
is through sustainable computing practices. This involves However, RAPL lacks native support in Windows sys-
using environmentally friendly materials in the production tems [33], thereby constraining the utility of RAPL-based
of computer systems and reducing waste by recycling old solutions for Windows users and developers. A project
computer systems [22, 23]. named Windows-RAPL-Driver [34] seeks to bridge this gap
Green data centers are another aspect of green comput- by furnishing a Windows driver enabling the gathering of
ing [24]. Data centers consume a large amount of energy due RAPL metrics from physical computers. This driver exposes
to their high-performance computing requirements. Green RAPL data via a device file accessible to user-space applica-
data centers aim to reduce this energy consumption using tions.
renewable energy sources such as solar or wind power. They
also use energy-efficient cooling systems that reduce the 2.4. GreenErl framework for Linux
amount of energy required to cool the data center. They also
implement different techniques such as reducing wasted re- The former work on Erlang green computing [5, 9] made
sources by tailoring the resources [25]. several important contributions, including the development
of GreenErl, a tool designed to measure the energy con-
sumption of Erlang programs. The GreenErl framework was
2.2. Erlang
developed using RAPL [35] to read the energy consump-
Erlang [26] is a general-purpose, concurrent, functional, tion. GreenErl comprised an Erlang module, a Python-based
high-level programming language [27, 28] that was devel- graphical user interface, and the rapl-read.c program,
oped by Ericsson in the late 1980s. It is used to build mas- making it user-friendly and effective in analyzing the energy
sively scalable soft real-time systems with requirements of usage of different language constructs and elements:
high availability [29, 30]. It can be used for a wide range of
applications, some of its uses are in telecoms [31], banking, • Rapl-read.c is responsible for reading the energy
e-commerce, computer telephony and instant messaging. consumption. The original source file was mod-
Erlang’s runtime system, the BEAM, has built-in support ified [32] to measure the energy consumption of
for concurrency, distribution and fault tolerance [30]. Erlang functions. Now it splits each measurement
Erlang has several features that make it unique among function into two parts: one that reads the values
programming languages and it also can serve as a runtime before the Erlang function is run, and one that reads
system [30]. One of these features as mentioned earlier the values after and calculates the energy difference.
is its native support for concurrency and distribution. Er- • The Erlang module, energy_consumption.erl,
lang’s concurrency model is based on lightweight processes communicates with the rapl-read.c program to
that are isolated from each other and communicate through measure the energy consumption of Erlang func-
message passing. This makes it easy to write concurrent pro- tions. The module has a measure function that
grams that can run on multiple processors or even multiple takes various parameters, such as the path to the
machines. rapl-read.c program, the functions to measure,
Another feature of Erlang is its support for fault tolerance. the inputs for the functions, the number of repeti-
Erlang programs are designed to be fault-tolerant, which tions, and the log file location. The module can also
means that they can continue to operate even if some parts generate inputs from input descriptors and measure
of the system fail. This makes Erlang an ideal choice for all exported functions in a module.
building systems that require high availability and reliabil- • The Python GUI is a tool that helps to organize
ity. and visualize the measurements. The GUI uses the
Erlang is a dynamically typed language, therefore er- TkInter library to create a user interface, where you
rors are only raised at runtime once types of functions and can select the Erlang file, the functions, and the in-
variables are checked at runtime. Additionally, Erlang is puts to measure. The GUI also allows building the
strongly typed, which means there is no implicit type con- rapl-read.c program and setting up the measure-
version. ments. It allows adding multiple measurements to
Erlang is usually mentioned as Erlang/OTP. OTP is a set a queue and running them one by one. After the
of Erlang libraries and design principles providing middle- measurements are done, you can use the matplotlib
ware to develop massively scalable soft real-time systems library to plot the results on a graph or export the
with requirements on high availability. It includes its own results to a latex graph.
distributed database, applications to interact with other lan-
guages, and debugging and release handling tools. These components communicate with each other. The
Python script uses the subprocess library to create the Erlang
shell and run the commands. The Erlang module spawns
2.3. RAPL
the rapl-read.c program and sends signals to start and
Running Average Power Limit (RAPL) [32] presents in con- stop the measurement. The rapl-read.c program reads
temporary Intel and AMD processors, facilitating the mea- the RAPL registers and sends the measured data back to the
surement and regulation of power usage across various Erlang module. Finally, the Erlang module creates the log
components such as CPU cores, memory, and the package. files, which are accessed by the Python script to visualize
RAPL grants access to power and energy counters through the results.
model-specific registers (MSRs), which can be accessed by GreenErl was used [5] to examine the energy consump-
software applications. tion of various data structures, such as proplists, maps,
and dictionaries and found significant differences in the
energy consumption of various operations. The study also common elements while integrating the chosen tool into the
explored the optimal scenarios for transforming lists into system. We then rigorously tested the framework and final-
maps and identified the limits and kinds of operations that ized the configuration parameters for optimal performance.
justify such a transformation. Subsequently, we conducted the measurement procedures
The effect of higher-order functions on energy consump- and carefully analysed the results obtained.
tion was also investigated and replacing higher-order func- A recent open-source tool called Scaphandre [8, 37] en-
tion calls with either a list comprehension or a specialized deavours to tackle these issues by offering a straightforward,
recursive function was suggested to decrease energy con- dependable, and transparent approach to assessing and min-
sumption. imizing the energy consumption of technological services.
The energy cost of different parallel language constructs The fundamental principle behind Scaphandre’s function-
were also examined, particularly the energy consumption ality lies in integrating two data sources: the proportion
of sending different data structures between processes. The of resources utilized by a process and the total power con-
study found that sending maps instead of lists can decrease sumption of the system. The latter relies on RAPL. We
energy consumption and suggested that transforming a list used Windows-RAPL-Driver [34] to provide the required
into a map can be a viable option for minimizing energy functionality,
consumption in parallel language constructs.
Finally, some refactorings were proposed
based on the findings, such as replacing calls to 3. The Scaphandre based energy
proplists:get_value/2 with the more efficient usage measuring tool-chain for
lists:keyfind/3, transforming a recursive function
definition that uses a property list as its parameter to use a
Windows
map instead, and eliminating higher-order function calls by Scaphandre presents numerous advantages over other watt
replacing calls to the lists:map/2 and lists:filter/2 meters concerning platform compatibility, measurement
functions with either a new recursive function or a list precision (with sampling rates down to one nano-second),
comprehension, depending on what the user desires. The and data output versatility (JSON format). It is operable
RefactorErl [36] framework was used to implement these on both Windows and Linux systems and compatible with
transformations [5, 7]. processors supporting the RAPL interface. Additionally,
Scaphandre can assess the power consumption of any pro-
2.5. Selecting the right environment for cess or application on both physical and virtual hosts. It of-
Windows fers the capability to transmit or expose power consumption
data to various data analysis or monitoring tools for further
A significant challenge in reducing the energy usage of tech processing and visualization, including JSON, Grafana, and
services is accurately and openly measuring it. However, wrap10. Consequently, Scaphandre emerges as a superior
most current tools and methods are either too expensive, choice for power consumption measurement across diverse
too complicated, or not straightforward enough to be widely scenarios, including the context of this work, and holds
used by providers and users. For example, some tools need promise for potential future enhancements.
special hardware or software that does not work on all To be able to run Scaphandre on Windows we needed to
devices. Others use indirect estimates or averages that do first install Windows-RAPL-Driver [34] to allow access to
not show the real power use of a particular service or device. metrics and then Scaphandre [38]2 .
The GreenErl framework was developed using RAPL [35] Upon selecting Scaphandre as the designated tool, we pro-
to read the energy consumption from the designated regis- ceeded to examine the pre-existing Unix-like OS GreenErl
ters. Since Windows does not have APIs that allow access framework [5], experimenting with various implementa-
to the needed model-specific registers [33], we need to find tions to determine the necessary edits and integration steps
a similar tool that allows us to reproduce the same mea- required. In this section, we will detail each component,
surements and findings on Windows Operating Systems outlining the adjustments made and ultimately presenting
with keeping in mind different constraints. The most im- the finalized implementation outcome.
portant constraint was that we would like to measure the
same Erlang modules meaning that we do not want to rede-
GreenErl for Windows implementation Our initial
fine new function descriptions to have the highest similar
aim in adapting the GreenErl framework for Windows was
environmental comparison. We also need to consider that
to maintain consistent functionality and input specifications
some functions are fast and have low energy consumption
with the original Linux-based version. This entailed utilizing
usage so the tool we should choose can handle values in
the existing Erlang modules as inputs for the Erlang measure
nano-seconds and micro-watts. The last constraint is that
module without necessitating modifications, wherever fea-
we need to have the values in a file so that we can plot it in
sible, as the objective was to conduct a comparative analysis
a graph and make the comparison.
of energy consumption between the two operating systems.
We explored various Windows utilities, such as Powercfg,
The process began with the removal of redundant functions
CPU-Z, Intel Power Gadget, and Scaphandre, to identify a
and parameters from the Erlang measure module to create
tool that satisfies our specific requirements. These criteria
a streamlined command-line version of GreenErl tailored
included the ability to accurately measure energy consump-
tion at the process level, maintain a rapid sampling rate,
detect even low levels of energy consumption, and facilitate 2
Throughout the installation process, we faced many challenges since
data storage in file (or other reusable, persistent storage) the framework was in an early phase of development. For those who
formats. Following this, we proceeded to adapt the Green- will try the framework in the future, there is new documentation and
Erl framework for compatibility with Windows, preserving explanation of the Windows-RAPL-Driver installation on the official
website [39] supporting Windows.
Figure 1: Workflow diagram of GreenErl on Windows
for Windows (without energy consumption data). Subse- in the measurement (Figure 2) and visualization (Figure 3)
quently, integration of the Scaphandre component ensued, figures. Leveraging the TkInter library for Python, we de-
alongside modifications to the Python script to facilitate veloped an intuitive GUI allowing users to select the Erlang
execution of the Erlang module. Finally, adjustments were file containing the module for assessment, specify functions
made to the Python script to visualize and export results in and inputs for measurement, and designate file paths for the
latex format. The revised implementation thus comprised Erlang module and result folders. Upon input completion,
three key components: an Erlang module, a Python script, measurements can be queued for execution. Furthermore,
and a Scaphandre command for data collection. we resolved path disparities between Windows and Linux,
removed redundant packages, and updated the LaTeX ex-
Erlang Module The Erlang module, denoted as porter. A function was introduced to compute consump-
energy_consumption_res.erl, exposes a single tion values from JSON files, accepting arguments for folder
function measure/3. This function receives three argu- path, count, input, and process ID (Pid) to ensure precise
ments: {Module, Functions, InputDescs}, Count, process-level consumption measurements. This function
ResultPath. Its purpose is to measure the energy also handles errors, logging them if encountered. The visu-
consumption across multiple functions, each executed with alization component (Figure 3) facilitates exporting LaTeX
various input sets and repetitions. Employing recursive files and visualizing results, requiring only the path to CSV
invocation, it iterates through the list of input descriptions files or folders. The interaction between these components
and utilizes the measureFunctions/3 function to assess is illustrated in Figure 1.
each function with respective input argument lists. Addi-
tionally, it verifies whether the module under measurement
features a function named generate_input, which, if
available, generates input argument lists from provided
descriptions. Otherwise, it treats the input descriptions
directly as argument lists.
The input description follows the format
{Value, Count}, where Value represents the in-
put value and Count signifies the number of repetitions
for that specific value within the function. We introduced
this capability to operate optionally if included in the input
description, recognizing that certain functions execute
swiftly with minimal energy consumption (approximately
0 Watts). In cases where the pattern {Value, Count}
is absent, the default Count specified in the measure/3
Figure 2: Python GUI to run the tool
parameter is utilized.
Python script Similar to the modifications made to the
Erlang module, we streamlined the graphical user interface The use of Scaphandre We integrated the Scaphandre
(GUI) components for Windows compatibility, as depicted tool into the Erlang measuring module. Tracking the module
tations, each repeated 10 times. The consistent success
observed across these iterations serves as compelling ev-
idence of the framework’s robustness and stability. This
outcome confirms its readiness for future measurements,
highlighting its reliability for continued use.
4. Analysing energy consumption
We performed various measurements on Windows to deter-
mine the energy behaviour of Erlang applications.
4.1. The measuring environment
The investigation into energy consumption across various
functions was performed using the GreenErl framework
for Windows, as outlined in Section 3. Each experiment
was repeated 10 times, a choice made based on previous
measurements that indicated a high level of consistency
through analysis of standard deviation and range. Addition-
ally, the runtime of the functions was measured. The data
Figure 3: Python GUI to visualize collected from these experiments were plotted and subjected
to detailed descriptive statistical analysis.
All measurements in this research were performed on a
function and input descriptions was facilitated by specific DELL XPS 13 9370 equipped with an Intel Core™ i5-8250U
names, as illustrated in Figure 4. This code segment handles CPU @ 1.60GHz 1.80 GHz, 8GB of DDR3 RAM, 64-bit oper-
the setup for generating the input JSON file name and con- ating system, x64-based processor, running Windows 11 Pro
structing the Scaphandre command. To execute Scaphandre, operating system Version 22H2. We used Erlang/OTP 23.3.4
we run the wmic process call create command from for the measurements. The previous Linux measurements
Windows Management Instrumentation (WMI) [40], and were conducted on a Toshiba Satellite L50 equipped with an
parse the output of the command to extract the PID of the Intel Core i7-4700MQ @ 2.4 GHz, 12GB of RAM, running
newly spawned Scaphandre process. This PID is crucial Ubuntu 16.04 LTS.
for terminating the Scaphandre process once the function To ensure the accuracy and reliability of our results, we
completes. implemented several additional measures to create a con-
We utilize the JSON exporter feature offered by Scaphan- trolled and consistent environment:
dre [41] to record the results into a JSON file. We
specify the file path along with its name. For instance, Minimization of Processes All non-essential processes
as illustrated in Figure 5, given a module named map, and applications were terminated prior to conducting the
a function named recursive, and an input descrip- measurements to eliminate any background activities that
tion of 100,000, the resulting JSON filename would be could introduce noise and affect the performance analysis.
map_recursive_100000.json. Subsequently, this JSON
file was employed by our Python script to compute the Hardware Consistency The measurements were con-
function’s energy consumption. ducted on a DELL XPS 13 9370 with the following specifi-
Scaphandre offers the default option to collect the con- cations: Intel CoreTM i5-8250U CPU @ 1.60GHz 1.80 GHz,
sumption data of the top 20 consumers. However, as de- 8GB of DDR3 RAM, 64-bit operating system, x64-based pro-
picted in Figure 5, we specified to gather data for the top 100 cessor. The Windows environment ran Windows 11 Pro
consumers explicitly. Through extensive experimentation Version 22H2. Erlang/OTP 23.3.4 was used for the measure-
with various consumer counts, we found that configuring ments.
it to 100 effectively covered all Erlang functions requiring
measurement. Operating System Services Only essential operating
The final crucial feature for optimizing measurements system services were active during the measurements to
and ensuring coherent results was determining the sam- avoid any extraneous influence on the results.
pling rate. By default, Scaphandre sets this feature to two
seconds [41], which proved inadequate for our requirements, Network and Connectivity The WiFi was turned off,
particularly given the swift execution of some functions ne- and the laptop was set to airplane mode during all measure-
cessitating a larger sampling rate. After experimenting with ments to prevent network-related processes from affecting
various sampling rates, we opted for the highest available the results.
option, which is nano-second sampling, as depicted in Fig-
ure 5. Nano-second sampling provided a significantly higher
System Initialization Each measurement was initiated
granularity of detail in the generated graphs. While this
on a fresh startup to ensure a clean state, free from any
increased granularity introduced potential fluctuations, we
residual processes or temporary files that could impact the
determined that the benefits outweighed the drawbacks, as
results.
it consistently yielded better results overall.
For experimental validation while determining the opti-
mal configurations, we conducted two distinct implemen-
...
InputDesFile = "\"" ++ ResultPath ++ atom_to_list(Module) ++ "_" ++ atom_to_list(Function) ++
"_" ++ integer_to_list(InputDesc) ++ ".json"++ "\"",
io:format("~nCurrently measuring functions with input description ~p~n",[InputDesc]),
% ns sampling
Command = "scaphandre json -s 0 -n 1 -m 100 -f " ++ InputDesFile,
Output = os:cmd("wmic process call create \""++ Command ++"\" | find \"ProcessId\""),
{match, [PidString]} = re:run(Output, "ProcessId = ([0-9]+)", [{capture, all_but_first, list}]),
Pid = list_to_integer(PidString),
...
Figure 4: A code snippet from the Erlang measure module
• Higher order functions
scaphandre json −t 10 −s 0 −n 1 −m 100 −f
result_path \map_recursive_100000.json • Parallel language constructs
• Algorithmic skeletons
Figure 5: JSON export example Data structures The objective of this study was to eval-
uate the energy efficiency of various data structures for
storing key-value pairs on Windows. We conducted a se-
Power Settings The power settings were configured to ries of experiments to measure the energy consumption of
’balanced’ mode to provide a consistent energy consumption different operations on these data structures and to analyze
environment without favoring performance or power saving the trade-offs of changing the representation by converting
excessively. the data to another format. Furthermore, we compared the
energy performance of alternative methods for executing
the same operation within a given data structure. The data
Battery and Power Management The laptop was fully
structures that we investigated in this study were:
charged and plugged into the AC during the measurements.
Screen brightness was set to the minimum level. The lap- • List of tuples (or proplists)
top was set to test mode as required by Scaphandre, and
• Map
the screen and sleeping features were disabled both on the
battery and when plugged in. • Dictionary
The operations we measured on these data structures are
User Interaction The laptop was not used during the the following:
measurements to avoid any additional load or interference.
By implementing these measures, we aimed to create a • Creating/Converting the data structures
controlled and consistent environment for conducting the • Finding the value belonging to a particular key
performance analysis, thereby enhancing the reliability of • Inserting a new key-value pair
our findings.
• Updating the value belonging to an existing key
These detailed conditions ensured that our measurements
• Deleting an existing element
were conducted under minimal interference, providing a
clear and accurate representation of the software programs’
energy consumption and performance.
Finding an element Among the observations, we found
that map implementations exhibited greater efficiency and
4.2. Types of measurements faster execution times. In contrast, all list implementations
The preceding study [5] conducted an original investigation consumed more energy and took longer to complete. This
into the energy consumption of complex algorithms in Er- finding is illustrated in the Figure 6.
lang. Specifically, it compared different implementations of
the N-queens problem and sparse matrix multiplication [6], Higher-order functions We also investigated the influ-
employing various techniques including higher-order func- ence of higher-order functions (HOFs) on energy consump-
tions, recursion, list comprehensions, lists, and arrays. Ad- tion. Based on the findings shown in Figure 7, both named
ditionally, other aspects of the research [5] focused on more function and lambda expression, exhibit consistently ele-
fundamental language elements rather than solely address- vated energy consumption. Conversely, using list compre-
ing complex problems. hension proves to be relatively more efficient, regardless of
In this measurement, we focus on comparing different im- whether a named function or lambda expression is utilized.
plementations of the same language element. Our detailed
results can be found in this thesis [10], as it is not feasible Parallel language constructs Erlang effortlessly sup-
to include all figures here. Additionally, all GreenErl for ports extensive concurrency through its simple primitives
Windows framework components can be found in the same for process creation and communication. Each process op-
repository 3 . Based on the previous findings, we selected erates within its own isolated memory space, exclusively
the following areas for this analysis: holding its data. To share data between processes, it must be
transmitted as messages. This research measures not only
• Data structures the energy consumption associated with creating, modi-
3
https://github.com/joegharbi/greenErl fying, and converting various data structures but also the
Figure 6: Finding an element using GreenErl on Windows
Figure 7: Higher-order functions using GreenErl on Windows
overhead of sending these structures between processes. We before requesting a new element. Finally, the collector ag-
aimed to determine whether optimizing data representation gregates the results. It is important to note that this skeleton
before transmission and upon reception could minimize does not maintain the order of the elements.
energy consumption.
We analysed the map/send function initiates a process 4.3. Comparing energy consumption
that interacts with the main process by exchanging a list
of key-value pairs along with a confirmation message. Sim- We aimed to compare the energy behaviour of Erlang appli-
ilarly, the list/send and dictionary/send functions cations on Linux and Windows operating systems. There-
communicate a list and a dictionary, respectively. We found fore, we will explore some of the trends between the two
that sending a list of tuples proves to be the least efficient operating systems.
in terms of energy consumption. Conversely, sending maps
demonstrates the highest efficiency, followed by the dictio- Data structures A noticeable distinction was observed
nary (Figures 8 and 9). between Linux and Windows environments when construct-
ing a dictionary as shown in Figure 10. Linux exhibited a
Algorithmic skeletons This study aimed to understand peak in energy consumption compared to other data struc-
how different parallel algorithmic skeletons impact energy tures, whereas Windows demonstrated a much lower peak.
consumption. These parallel programming patterns are Interestingly, the remaining functions displayed consistent
extensively used due to their ability to simplify the complex- behaviour across both operating systems.
ities of parallel and distributed applications, highlighting On the other hand, we observed that most functions ex-
the importance of investigating their energy usage implica- hibited similar behaviour. For instance, when deleting an
tions. In this research, we evaluated fundamental skeletons element from a list, as illustrated in Figure 11.
such as farm and pipeline skeletons. Additionally, consid-
ering the potential combinations of these patterns, we also
assessed various compositions of skeletons. Inference The Linux kernel for servers has been specifi-
For instance, the task farm is a widely used parallel pro- cally optimized for high throughput and performance [42],
gramming pattern to parallelise the evaluation of a function prioritizing processing efficiency over power consumption.
for all elements of an input structure. To implement it, three Consequently, Linux distributions tend to consume more
key members with distinct roles are defined. The dispatcher power and battery life compared to Windows and Mac op-
is responsible for managing the input and distributing ele- erating systems [43]. Although the aim of this investigation
ments to the workers. Each worker executes the function is not to prove which Operating System is more efficient as
on assigned inputs and forwards the results to the collector
Figure 8: Sending of elements from a container
Figure 9: Sending of elements from a container
stated in the introduction, nevertheless our findings showed Windows versus Linux operating systems To fairly
that Windows behaved in a more efficient way than Linux. compare and study the energy consumption differences be-
As previously mentioned, comprehensive results are doc- tween Linux and Windows, we first need to understand the
umented in this thesis [10]. fundamental key differences between these operating sys-
tems. A detailed study was conducted by Hadeel et al [44]
where they reviewed the history and development of both
5. Related work systems and their market share and user base. They also
discussed the technical aspects of the systems, such as the
We are investigating the related works from different per-
kernel, the file system, the security model, the user interface
spectives. We are summarising the studies related to func-
and the compatibility with hardware and software. One of
tional programming and related to comparisons of operating
the major differences is the process scheduling, where they
systems and programming languages.
compared the scheduling algorithms used by Linux kernel
2.6 and Windows NT-based versions, and analyzed their
Figure 10: Different behavior of dictionary on Linux and Windows
Figure 11: Different behavior of deleting an element on Linux and Windows
trade-offs between fairness and responsiveness. Another type (interpreted or compiled) and the programming
dissimilarity is in memory management, where they evalu- paradigm (imperative, object-oriented or functional) on
ated different paging strategies for Linux and Windows and energy efficiency.
examined the impact of swap partition and pagefile on disk The main findings are that compiled languages are more
fragmentation and system performance. energy-efficient than interpreted ones and that functional
Another study by Beatriz Prieto et al [45] on the energy languages are more energy-efficient than imperative or
efficiency of personal computers compared to mainframe object-oriented ones. The researchers also identified C, Rust,
computers and supercomputers, where the authors explored Ada and Pascal as the most energy-efficient languages, and
the possibility of running scientific and engineering pro- Perl, JRuby, Python and Lua as the least energy-efficient
grams on personal computers and measuring these systems’ ones. They also found interesting correlations between en-
power efficiency. They also showed how the power effi- ergy, time and memory, such as slower languages consum-
ciency obtained for the same workloads on personal com- ing less energy and memory usage influencing energy con-
puters is similar and sometimes less than that obtained on sumption such as languages with comparable energy con-
supercomputers included in the Green500 [46] ranking. This sumption can have significantly different execution times.
study reveals that energy consumption not only can vary For instance, in the binary trees benchmark, Pascal con-
between operating systems but also when using different sumed approximately 10% less energy than Chapel, but
makers where they used five different personal computers Chapel executed about 55% faster than Pascal. This finding
with different processors of different generations. emphasizes the results that we found in this paper, where
A comparative analysis was performed by Sayed Naj- the parallel implementation of the identity function with
muddin et al [47] of the power and battery consumption two workers was the slowest but with the least energy con-
of Windows operating systems and modern Linux distribu- sumption, which was the same finding for the previous
tions, such as Ubuntu, Fedora, Debian, Red Hat, and others. thesis work [5].
They argued that one of the main factors that affect the The authors used a tool called CodeCarbonFootprint
power management of Linux is the quality of the drivers, (CCF) to measure the energy consumption of each language
which are often poorly written or incompatible with the and problem. The experiments were performed on a desktop
hardware. The researchers also explained that this is due computer with the following configuration: 16GB of RAM,
to the reluctance of hardware manufacturers to share the an Intel® Core™ i5-4460 CPU @ 3.20GHz with a Haswell mi-
details of their products with driver developers, especially croarchitecture, and a Linux Ubuntu Server 16.10 operating
those who work for open-source operating systems. They system.
also pointed out that some versions of the Linux kernel are Another important aspect of programming languages
not properly designed and optimized for mobile systems, and their energy consumption can be linked to the mis-
as they are mainly intended for desktop platforms. They use of data structures or engineering solutions. This can
concluded by recommending that users should select the be illustrated in the research done by Meszaros et al [6]
most suitable and efficient kernel for their system as a way where they measured the energy consumption of Erlang
to improve the power and battery performance of Linux. programs and discovered patterns and relations between
All of the previously mentioned research proves the fact language constructs and power consumption. They cre-
that Windows and Linux differ radically from each other. ated a framework to make the measurement user-friendly.
This framework uses RAPL to read the access the energy
Programming languages efficiency Rui Pereira consumption values. All measurements were done using
et al [48] presented a study of the energy efficiency of 27 Intel(R) Core(TM) i5-6200U CPU @ 2.30GHz and 8 GB of
programming languages, using 10 different algorithms. The DDR3 RAM @ 1600MHz, using Ubuntu 16.04 LTS. They
authors measured the time, CPU usage, memory usage and found that eliminating higher-order functions may result in
energy consumption of each program execution, and used a more efficient program. They also found that using naive
statistical methods to rank the languages according to each parallelisation solutions can result in the worst consump-
objective. They also analyzed the impact of the execution tion due to the fact of spawning different processes which
was the case in our results mentioned in this paper and the worst in terms of energy consumption, the dictionary was
thesis containing the details of the work [10]. better except while updating all of its elements. We also
More recent research that incorporates hardware mea- measured some higher-order functions like applying a func-
surement setups to evaluate energy consumption is also tion on filtered elements where recursive implementations
noteworthy. Koedijk and Oprescu’s 2022 study, "Finding were the most efficient. Since one of the many strengths
significant differences in the energy consumption when of Erlang is parallelization, We also measured sending data
comparing programming languages and programs," [49] in different forms. Lastly, we assessed some algorithmic
presented at the International Conference on ICT for Sus- skeletons such as task farms where we concluded it is better
tainability (ICT4S), identified substantial variations in en- to spawn as many workers as the number of your physical
ergy usage across different programming languages. Their processes.
results indicated that certain languages, such as C and Rust, As for the comparison section, we can say the trend in
tend to be more energy-efficient compared to higher-level both operating systems had more similarities than differ-
languages like Python and JavaScript. They also found sig- ences with some exceptions. For example, the dictionary
nificant variations in energy consumption based on lan- had a lower consumption on Windows and a noticeably dif-
guage choice and programming techniques. While C and ferent overall behaviour while being the highest consumer
C++ consistently exhibit lower energy consumption across in Linux except for updating all elements in the dictionary
the tested programs, they note that energy usage can vary that resulted in it being as high in Windows as in Linux. We
depending on compiler optimization settings. This study’s also noticed that Windows results had higher fluctuating
findings provide valuable insights and a more detailed un- values compared to Linux, this can be due to the difference
derstanding of the energy efficiency landscape, underscor- in the sampling rates between RAPL [52] and Scaphandre.
ing the importance of considering hardware-level data and
compiler optimizations in energy consumption analysis for Future work As Scaphandre is still in an early stage, we
software development. think it is a good approach to focus on this tool to create
a cross-platform GreenErl for (Linux, Windows, VMs, and
Functional languages Luis Gabriel Lima et al [50, 51]. Containers). Using the same tool to get the values will give
conducted studies specifically targeting the energy effi- genuine comparable results.
ciency of functional programming languages, focusing
on Haskell. Their research, "On Haskell and energy effi-
ciency" [50], and "Haskell in Green Land: Analyzing the Acknowledgments
Energy Behavior of a Purely Functional Language" [51], ex-
This work is partially supported by CERCIRAS COST Action
amined Haskell’s energy consumption characteristics. They
CA19135 funded by COST Association.
evaluated various Haskell programs to understand the im-
Project no. TKP2021-NVA-29 has been implemented with
pact of different language features on energy usage. The
the support provided by the Ministry of Culture and Innova-
studies revealed that Haskell, due to its purely functional
tion of Hungary from the National Research, Development
nature, often exhibited favorable energy consumption pat-
and Innovation Fund, financed under the TKP2021-NVA
terns compared to other programming languages. They also
funding scheme.
found that small changes can make a big difference in terms
of energy consumption. These findings underscore the im-
portance of considering functional languages like Haskell References
when analyzing energy efficiency in software development.
[1] I. , What is green computing?, 2022. URL: https://www.
ibm.com/cloud/blog/green-computing.
6. Conclusion [2] A. A. Chien, Computing’s grand challenge for sus-
tainability, Commun. ACM 65 (2022) 5. URL: https:
Green computing is important for all kinds of systems, from
//doi.org/10.1145/3559163. doi:10.1145/3559163.
handheld devices to large-scale data centres. It can help
[3] S. Unge, How cisco is using erlang for intent-based
reduce greenhouse gas emissions energy consumption, and
networking, 2020. URL: https://codesync.global/
electronic waste. It can also save costs and improve perfor-
media/how-cisco-is-using-erlang-for-intent-based-/
mance for technology makers and users. This thesis was
networking-cbf20/.
a complementary work to the previous findings of our re-
[4] A. the, Datareportal – global digital in-
search team. Previously, the work was only focused on
sights, 2013. URL: https://datareportal.com/
Unix-like operating systems, thus this thesis was a first step
global-digital-overview#:~:text=Internet%20use%
into bridging the gap between these different platforms.
20around%20the%20world,million%20new%20users%
As a first step, we started by looking for a tool to fill
20every%20day.
the gap between the two operating systems since RAPL
[5] G. N. Áron Attila Mészáros, GreenErl Measuring the
is not available in Windows. Thus we used Scaphandre
energy consumption of Erlang programs and energy
since it checked all of the boxes for our constraints. We
conscious refactorings, Master’s thesis, Eötvös Loránd
integrated the tool with the previous GreenErl framework
University, Faculty of Informatics, Department of Pro-
and measured different Erlang functions.
gramming Languages and Compilers, 2019.
There were some nice findings about Erlang on Win-
[6] A. Mezsaros, G. Nagy, I. Bozo, M. Toth, Towards green
dows. We measured the energy consumption and runtime
computing in erlang, Studia Universitatis Babes, -
of some data structure implementations such as lists, maps
Bolyai Informatica 63 (2018) 64–79. URL: https://www.
and dictionaries. We evaluated creating, converting, up-
readcube.com/articles/10.24193%2Fsubbi.2018.1.05.
dating, searching and deleting elements from those data
doi:10.24193/subbi.2018.1.05.
structures where we found that in most cases list is the
[7] G. Nagy, A. A. Mészáros, I. Bozó, M. Tóth, Tools [21] H. Castro, G. Sotelo, C. O. Diaz, P. Bouvry, Green
supporting green computing in erlang, in: Pro- flexible opportunistic computing with virtualization,
ceedings of the 18th ACM SIGPLAN International in: 2011 IEEE 11th International Conference on Com-
Workshop on Erlang, Erlang 2019, Association for puter and Information Technology, 2011, pp. 629–634.
Computing Machinery, New York, NY, USA, 2019, p. doi:10.1109/CIT.2011.105.
30–35. URL: https://doi.org/10.1145/3331542.3342570. [22] T. V. Kumar, P. Kiruthiga, Green computing -
doi:10.1145/3331542.3342570. an eco friendly approach for energy efficiency
[8] Hubblo, Scaphandre documentation, 2023. URL: https: and minimizing e-waste 3 (2014) 356–359. URL:
//hubblo-org.github.io/scaphandre-documentation/ https://www.academia.edu/6943675/Green_
index.html. Computing_An_Eco_friendly_Approach_for_
[9] J. T. C. Ortiz, Green computing in Erlang, Master’s the- Energy_Efficiency_and_Minimizing_E_Waste.
sis, Eötvös Loránd University, Faculty of Informatics, [23] L. Goldberg, The advent of "green" computer design,
Department of Programming Languages and Compil- Computer 31 (1998) 16–19. doi:10.1109/2.708445.
ers, 2017. [24] D. Çavdar, F. Alagoz, A survey of research on green-
[10] Y. Gharbi, Green computing for Erlang, Mas- ing data centers, in: 2012 IEEE Global Communica-
ter’s thesis, Eötvös Loránd University, Budapest, tions Conference (GLOBECOM), 2012, pp. 3237–3242.
Hungary (Faculty of Informatics, Department of doi:10.1109/GLOCOM.2012.6503613.
Programming Languages and Compilers), 2023. URL: [25] J. Torres, D. Carrera, K. Hogan, R. Gavalda, V. Beltran,
https://github.com/joegharbi/greenErl/blob/main/ N. Poggi, Reducing wasted resources to help achieve
papers/YoussefGharbi_IKYCUE_THESIS.pdf. green data centers, 2008 IEEE International Sympo-
[11] I. Ray, Green computing, 2012. URL: https: sium on Parallel and Distributed Processing (2008).
//www.researchgate.net/publication/270570843_ URL: https://ieeexplore.ieee.org/abstract/document/
Green_Computing. 4536219. doi:10.1109/ipdps.2008.4536219.
[12] B. Saha, Green computing, International Journal of [26] F. Cesarini, S. Thompson, Erlang programming,
Computer Trends and Technology (IJCTT) 14 (2014) O’Reilly, 2009. URL: http://shop.oreilly.com/product/
46–50. doi:10.14445/22312803/IJCTT-V14P112. 9780596518189.do.
[13] L. Ardito, G. Procaccianti, M. Torchiano, A. Vetrò, [27] F. Cesarini, S. J. Thompson, Erlang Programming,
Understanding green software development: A con- O’Reilly Media, Inc., United States of America, 2009.
ceptual framework, IT Professional 17 (2015) 44–50. [28] J. Armstrong, Programming Erlang: Software for a
doi:10.1109/MITP.2015.16. Concurrent World, The Pragmatic Bookshelf, United
[14] S. Podder, A. Burden, S. Kumar Singh, R. Maruca, How States of America, 1993.
green is your software?, 2020. URL: https://hbr.org/ [29] J. Armstrong, The development of erlang, in: Pro-
2020/09/how-green-is-your-software. ceedings of the Second ACM SIGPLAN International
[15] I. Manotas, C. Bird, R. Zhang, D. Shepherd, C. Jaspan, Conference on Functional Programming, ICFP ’97, As-
C. Sadowski, L. Pollock, J. Clause, An empirical study sociation for Computing Machinery, New York, NY,
of practitioners’ perspectives on green software en- USA, 1997, p. 196–203. URL: https://doi.org/10.1145/
gineering, in: Proceedings of the 38th International 258948.258967. doi:10.1145/258948.258967.
Conference on Software Engineering, ICSE ’16, As- [30] J. Armstrong, A history of erlang, in: Proceed-
sociation for Computing Machinery, New York, NY, ings of the Third ACM SIGPLAN Conference on His-
USA, 2016, p. 237–248. URL: https://doi.org/10.1145/ tory of Programming Languages, HOPL III, Asso-
2884781.2884810. doi:10.1145/2884781.2884810. ciation for Computing Machinery, New York, NY,
[16] N. Gholipour, E. Arianyan, R. Buyya, Recent Advances USA, 2007, p. 6–1–6–26. URL: https://doi.org/10.1145/
in Energy Efficient Resource Management Techniques 1238844.1238850. doi:10.1145/1238844.1238850.
in Cloud Computing Environments, Springer, 2021, [31] J. Armstrong, S. Virding, Erlang - an experimental
p. 29. telephony programming language, in: International
[17] B. S, Predicate path expressions, in: Proceedings of Symposium on Switching, volume 3, 1990, pp. 43–48.
the UGC Sponsored National Conference on Advanced doi:10.1109/ISS.1990.765711.
Networking and Applications, Advanced Networking [32] V. M. Weaver, Reading RAPL en-
and Applications (IJANA), 2015, pp. 107–112. URL: ergy measurements from Linux,
https://www.ijana.in/Special%20Issue/file24.pdf. http://web.eece.maine.edu/~vweaver/projects/rapl/,
[18] A. Kaur, D. Gupta, D. Verma, Making cloud computing 2015.
more efficient, International Journal of Advanced Re- [33] tools/power/rapl — firefox source docs documenta-
search in Computer Science and Software Engineering tion, 2023. URL: https://firefox-source-docs.mozilla.
4 (2014). org/performance/tools_power_rapl.html#windows.
[19] J. Shamir, Energy efficient computing exploiting the [34] Hubblo, Windows driver to get RAPL met-
properties of light, in: J. Ojeda-Castaneda, M. J. Yzuel, rics, 2023. URL: https://github.com/hubblo-org/
R. B. Johnson (Eds.), Tribute to H. John Caulfield, windows-rapl-driver.
volume 8833, International Society for Optics and [35] Rapl - powerapi, 2023. URL: https://powerapi.org/
Photonics, SPIE, 2013. URL: https://doi.org/10.1117/ reference/formulas/rapl/.
12.2024487. doi:10.1117/12.2024487. [36] I. Bozó, D. Horpácsi, Z. Horváth, R. Kitlei, J. Köszegi,
[20] G. Konduri, J. Goodman, A. Chandrakasan, Energy T. M., M. Tóth, Refactorerl - source code analysis
efficient software through dynamic voltage scheduling, and refactoring in erlang, in: Proceedings of the 12th
in: 1999 IEEE International Symposium on Circuits Symposium on Programming Languages and Software
and Systems (ISCAS), volume 1, 1999, pp. 358–361 Tools, ISBN 978-9949-23-178-2, Tallin, Estonia, 2011,
vol.1. doi:10.1109/ISCAS.1999.777877. pp. 138–148.
[37] scaphandre - rust, 2023. URL: https://docs.rs/ G. Melfe, J. P. Fernandes, Haskell in green land: An-
scaphandre/latest/scaphandre/. alyzing the energy behavior of a purely functional
[38] Hubblo, Scaphandre: Energy consumption metrol- language, in: 2016 IEEE 23rd International Conference
ogy agent, 2023. URL: https://github.com/hubblo-org/ on Software Analysis, Evolution, and Reengineering
scaphandre. (SANER), volume 1, 2016, pp. 517–528. doi:10.1109/
[39] Hubblo, Compilation for windows, 2023. URL: https: SANER.2016.85.
//hubblo-org.github.io/scaphandre-documentation/ [52] K. N. Khan, M. Hirki, T. Niemi, J. K. Nurminen, Z. Ou,
tutorials/compilation-windows.html. Rapl in action: Experiences in using rapl for power
[40] WMI command-line (WMIC) utility - Win32 apps, measurements, ACM Trans. Model. Perform. Eval.
2023. URL: https://learn.microsoft.com/en-us/ Comput. Syst. 3 (2018). doi:10.1145/3177754.
windows/win32/wmisdk/wmic.
[41] Hubblo, JSON exporter for Scaphandre,
2023. URL: https://hubblo-org.github.io/
scaphandre-documentation/references/
exporter-json.html.
[42] V. Srinivasan, G. R. Shenoy, S. Vaddagiri, D. Sarma,
Energy-aware task and interrupt management in linux,
in: Proceedings of the Linux Symposium, volume 2,
2008. URL: http://www.cs.columbia.edu/~nahum/
w6998/papers/ols-2008-srinivasan-energy.pdf.
[43] S. Najmuddin, Z. Atal, R. A. Ziar, Compar-
ative analysis of power consumption of the
linux and its distribution operating systems vs
windows and mac operating systems., Kardan
journal of engineering and technology (2021). URL:
https://kardan.edu.af/data/public/files/KJET-%203.
1-2021-06%20Linux%20Kernel19012022120259.pdf.
doi:10.31841/KJET.2021.21.
[44] H. T. Al-Rayes, Studying main differences between
linux & windows operating systems, IJECS: Interna-
tional Journal of Electrical and Computer Sciences 12
(2012) 25–31.
[45] B. Prieto, J. J. Escobar, J. C. Gómez-López, A. F. Díaz,
T. Lampert, Energy efficiency of personal computers:
A comparative analysis, Sustainability 14 (2022) 12829.
URL: https://www.mdpi.com/2071-1050/14/19/12829.
doi:10.3390/su141912829.
[46] Top500, 2013. URL: https://www.top500.org/.
[47] S. Najmuddin, Z. Atal, R. A. Ziar, Comparative
analysis of power consumption of the linux and
its distribution operating systems vs windows...,
2021. URL: https://www.researchgate.net/publication/
361225454_Comparative_Analysis_of_Power_
Consumption_of_the_Linux_and_its_Distribution_
Operating_Systems_vs_Windows_and_Mac_
Operating_Systems.
[48] R. Pereira, M. Couto, F. Ribeiro, R. Rua, J. Cunha, J. P.
Fernandes, J. Saraiva, Energy efficiency across pro-
gramming languages: how do energy, time, and mem-
ory relate?, Proceedings of the 10th ACM SIGPLAN
International Conference on Software Language En-
gineering - SLE 2017 (2017). doi:10.1145/3136014.
3136031.
[49] L. Koedijk, A. Oprescu, Finding significant differences
in the energy consumption when comparing program-
ming languages and programs, in: 2022 International
Conference on ICT for Sustainability (ICT4S), 2022, pp.
1–12. doi:10.1109/ICT4S55073.2022.00012.
[50] L. G. Lima, F. Soares-Neto, P. Lieuthier, F. Castor,
G. Melfe, J. P. Fernandes, On haskell and energy
efficiency, Journal of Systems and Software 149
(2019) 554–580. URL: https://www.sciencedirect.com/
science/article/pii/S0164121218302747. doi:https://
doi.org/10.1016/j.jss.2018.12.014.
[51] L. G. Lima, F. Soares-Neto, P. Lieuthier, F. Castor,