tag:blogger.com,1999:blog-88949859114553977982024-03-13T22:52:32.224-07:00My experiences as Masters' studentKaranhttp://www.blogger.com/profile/00549420716366311016noreply@blogger.comBlogger2125tag:blogger.com,1999:blog-8894985911455397798.post-55023814005432644122014-05-26T08:46:00.002-07:002014-05-28T17:55:04.523-07:00MSR presentation<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/Q6t-qfQCWbM?feature=player_embedded' frameborder='0'></iframe><br />
<span style="text-align: center;"><span style="color: #444444; font-size: large;">MSR Presentation Longer version</span></span><br />
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
<br /></div>
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/H51ABKBm13A?feature=player_embedded' frameborder='0'></iframe><br />
<span style="text-align: center;"><span style="color: #444444; font-size: large;">MSR Presentation Shorter version</span></span><br />
<br />Karanhttp://www.blogger.com/profile/00549420716366311016noreply@blogger.com0tag:blogger.com,1999:blog-8894985911455397798.post-79406265084641542322014-05-16T13:57:00.003-07:002014-08-25T10:11:15.429-07:00The Power of System Call Traces: Predicting the Software Energy Consumption Impact of Changes<div style="margin-bottom: 0cm;">
This blog post is from the work - “The
Power of System Call Traces: Predicting the Software Energy
Consumption Impact of Changes” that has been accepted at CASCON 2014 to be held at Toronto from 3-5 November 2014 .
The work relates the energy consumption of android applications to
system calls made by the application. You can find the work <a href="http://webdocs.cs.ualberta.ca/~kaggarwa/Cascon2014.pdf">here</a>.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
Limited battery life is a pressing
issue for the common smart phone users. This has forced the
developers to consider the energy profile of their application.
However, profiling energy consumption of an application requires
special external instrumentation for measuring the current and voltage
reading to estimate the power consumption. Studies have shown that on
device measurements are not reliable. Thus, developers for the most
part are clueless about the impact of software change on their
application's energy profile.</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
System calls, act as buffer between the
OS and the applications to provide the OS services and resources to
the applications. It is hence, interesting to consider the
relationship between the energy profile and system call trace of the
application. So, we considered two applications – Firefox and
Calculator on Android. We took 101 and 156 versions of the
Calculator<sup>1 </sup>and Firefox<sup>2</sup> applications
respectively, with each version being separated by one commit in
their repositories.
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
To get the system call trace, we use
the <i>strace</i> tool , that needs to be cross compiled for
Android<sup>3</sup>. The strace executable cross-compiled needs to be
placed either on the phone or even on a system that's connected to
phone. To trace an application just use “strace -c <i>appProcessID”,
</i><span style="font-style: normal;">after starting the application</span><sup><span style="font-style: normal;">4</span></sup><i>.
</i><span style="font-style: normal;">If it is on the system,
connected to phone, the command can be run from the adb shell. For
the Calculator application, we had 26 different system calls made,
while for the Firefox we had 53 different system call invocation.</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">You
will also like to device a particular test sequence, for the
applications, which can then be emulated on the phone using the
monkey script runner. To devise the tests, you will need to emulate
the test sequence on the android emulator, which ships with the
Andorid studio. Just enable the developer options tool on the device,
which helps to note the pixel values of the screen. To emulate a
touch action on the phone, we note the pixel value at the screen
where touch is made. Similarly, for a swipe action , we note
the
starting and ending pixels on the screen. The emulator provides the
option to
note the pixel values at each tap or swipe on the
emulator
screen.
Using this noted sequence, we need to build the
monkey script, that can be run on the phone using the monkey runner,
that also ships with the android -sdk, and needs android-ndk.</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">We had
a special test bed to measure the energy use, called </span><i>Green
Miner. </i><span style="font-style: normal;">We tried to establish the
relationship between system call counts and energy usage of the
applications. We did multiple tests for each version to see whether,
a change in the system call trace leads to a significant change in
the energy use. To achieve this, we use the Student's </span><i>t</i><span style="font-style: normal;">-tests
to establish whether the two consecutive versions are same with
respect to system call profile and energy consumption. Now,
developers are not statisticians, so we tried to formulate a rule of
thumb to help them say whether they should be concerned when their
system call count change. </span>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">To do
so, we calculate simple frequency of occurrence of this phenomenon,
“Significant Change in system call count leads to significant
change in energy consumption”. To see the significant change in
the applications, system call count, </span><i>strace</i><span style="font-style: normal;"> the previous version and
as well </span><i>strace</i><span style="font-style: normal;"> the next version after the change in the application
code, multiple times, say 10 times. Then to see whether the change in
the system call count is significant, use the </span><i>t-</i><span style="font-style: normal;">tests.
Example below shows the same in R, where the 3-D matrix sysCounts,
contains the system call counts for the ten runs for a version:</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">ttestResult
<- array(0,dim=c( 100,26 ))
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">noSysCalls
<- array(0,dim=c(26, 10 , 101)) </span>
</div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">/*
Read the data to noSysCalls matrix */</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">for (y
in 1:noSysCalls)
</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">{</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;"> for
(i in 1:(noVersions-1))</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;"> {</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;"> tvalue
= t.test(sysCounts[y,,i],sysCounts[y,,i+1])</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;"> ttestResult[i,y]=tvalue$p.value</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;"> }</span></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">}</span></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">ttestResult
saves the result of the Student's </span><i>t</i><span style="font-style: normal;">-test.
To test the significance of change between versions we need to see
p-value < 0.05. </span>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">For
the Calculator application results were astounding, some system calls
like </span><i>pread,</i><span style="font-style: normal;"> or </span><i>stat64
</i><span style="font-style: normal;">had</span><i> 100% </i><span style="font-style: normal;">frequency
of occurrence of this phenomenon while on an average for each system
call, this phenomenon occurred 58% of the times. For the Firefox,
application, with the sheer number of system calls as compared to the
Calculator application, this average frequency rate is 25%. Hence,
with once in four times, a system call's count changes significantly
from the previous one, we can say that there is a change in the
energy profile of the application. </span>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<span style="font-style: normal;">This
saves the developers from the worry of setting up an exclusive and
expensive instrumentation to measure the power use, to see the impact
of software change on the energy. They just need to use the </span><i>strace</i><span style="font-style: normal;">
to profile the system calls. Hence, developers just need to notice
the change in the system calls profile, and hence can expect the
change in energy use of their applications. </span>
</div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<br /></div>
<div style="margin-bottom: 0cm;">
<sup><span style="font-style: normal;">1
</span></sup><span style="font-style: normal;">https://github.com/Xlythe/android_packages_apps_Calculator/</span></div>
<div style="margin-bottom: 0cm;">
<sup><span style="font-style: normal;">2
</span></sup><span style="font-style: normal;">http://ftp.mozilla.org/pub/mozilla.org/firefox/nightly/latest-mozilla-central/</span></div>
<div style="margin-bottom: 0cm;">
<sup><span style="font-style: normal;">3</span></sup><span style="font-style: normal;">
http://muzso.hu/2012/04/21/how-to-compile-strace-for-use-on-an-android-phone-running-an-arm-cpu</span></div>
<div style="margin-bottom: 0cm;">
<sup><span style="font-style: normal;">4
</span></sup><span style="font-style: normal;">http://mohsin-junaid.blogspot.ca/2012/12/how-to-strace-your-android-application.html</span></div>
<br />
<div style="margin-bottom: 0cm;">
<br /></div>
Karanhttp://www.blogger.com/profile/00549420716366311016noreply@blogger.com0