<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Using Reference Attribute Grammar-Controlled Rewriting for Runtime Resource Management</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Johannes Mey</string-name>
          <email>johannes.mey@tu-dresden.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>René Schöne</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Daniel Langner</string-name>
          <email>daniel.langner@mailbox.tu-dresden.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Christoff Bürger</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Chair of Software Technology</institution>
          ,
          <addr-line>TU Dresden</addr-line>
          ,
          <country country="DE">Germany</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Department of Computer Science, Faculty of Engineering, Lund University</institution>
          ,
          <country country="SE">Sweden</country>
        </aff>
      </contrib-group>
      <pub-date>
        <year>2016</year>
      </pub-date>
      <fpage>2</fpage>
      <lpage>6</lpage>
      <abstract>
        <p>To make distributed systems resource aware and adaptive, they can be modeled as self-adaptive systems. Such systems have a view of their own state and context, which can be represented by a model that is continuously updated and analyzed at runtime. However, such analyses need to be concise and efficient to allow large models and high adaptation rates. To achieve this, we apply reference attribute grammar controlled rewriting to implement the runtime model of a distributed task-scheduling case study for energy optimization.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Self-adaptive systems [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ] are used to cope with changing requirements and
contextual information at runtime. Furthermore, they need to provide short
response times while maintaining low resource consumption and a convenient
way to specify their internal state and algorithms. Another challenge is the high
update rate of their context information[
        <xref ref-type="bibr" rid="ref2">2</xref>
        ]. Self-adaptive systems usually employ
a feedback loop, e.g. MAPE-K [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ], and have representation of their context,
e.g. a runtime model. The models@run.time approach [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] uses models not only
during development but also as a data representation at runtime. It has been
shown that auto tuning and resource awareness can save energy in Big Data
scenarios [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. Our use case is a small, yet scalable, distributed Big Data scenario
on a network of embedded devices. We use a self-adaptive system built around a
runtime model, which is easy to specify, and can run algorithms efficiently with
regard to response time. It employs grammar-based modeling and analysis to
deal with frequent model updates efficiently.
Our solution uses reference attribute grammars [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ] (RAGs) as its underlying
technology. RAGs originate from the area of compiler construction to describe
abstract syntax trees of program code. However, their intrinsic advantage –
incremental evaluation – fits well to the described problems. Using RAGs, we
describe the structure of runtime models with a context free grammar that is
well-suited for hierarchical structures. Non-hierarchical parts of a model can be
described as well using reference attributes forming arbitrary overlay graphs. The
analysis of runtime data is done using attributes, which are defined declaratively
for specific non-terminals, achieving a concise specification.
      </p>
      <p>
        However, the aforementioned updates of the runtime model hinder incremental
evaluation commonly used in RAG systems since they rewrite the AST and
therefore invalidate all previously performed analyses. This work uses a novel
approach called RAG-controlled rewriting (RACR) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ], which treats model changes
as term rewrites [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. This enables the tracking of dynamic dependencies between
attributes and the model, and thus incremental evaluation across model changes.
Therefore, constantly changing self-adaptive systems can be analyzed efficiently,
thus allowing a more frequent analysis and larger model sizes.
3
      </p>
    </sec>
    <sec id="sec-2">
      <title>Runtime Models with RACR</title>
      <p>RACR works in a three-phase process. In the first phase, a context free grammar
with inheritance describing the runtime model is specified, like the one depicted
below for our case study presented in section 4. Terminals are in lowercase and
non-terminals in title case optionally suffixed by an alternative name and a colon.</p>
      <p>Root ::= scheduler switching CompositeWorker
AbstractWorker ::= id state timestamp
CompositeWorker : AbstractWorker ::= AbstractWorker *
Switch : CompositeWorker ::=
Worker : AbstractWorker ::= devicetype Queue : Request *
Request ::= id size deadline dispatchtime
The second phase involves the attribution, that is the specification of attributes
for certain non-terminals. Below, the schedule attribute defined for Root is listed.
It reads the terminal scheduler and invokes an attribute to find an insertion
position. All attributes and rewrites are written Scheme, using the API functions
ast-child, create-ast and att-value to get a certain child of a AST node,
create a new AST node and call an attribute, respectively.</p>
      <p>( ag-rule schedule
( Root ( lambda ( n time work-id load-size deadline )
( att-value ( ast-child ’ scheduler n ) n</p>
      <p>time work-id load-size deadline ))))
At runtime, the system is performing rewrites and attribute evaluations in turns.
Rewrites, like the one shown below, change the model and invalidate cached
attribute values. If those attributes are called, RACR ensures their re-evaluation.
( rewrite-insert
( ast-child ’ Queue worker ) ; l i s t node t o i n s e r t i n t o
index ; p o s i t i o n o f i n s e r t i o n
( create-ast ’ Request ( list id size deadline #f )))
; s u b t r e e f o r t h e new r e q u e s t</p>
      <sec id="sec-2-1">
        <title>1. reads</title>
        <p>Root schedule
scheduler: l.c.s schedule-shortest-queue
switching: 1-3
schedule-load-consolidating</p>
      </sec>
      <sec id="sec-2-2">
        <title>2. calls</title>
      </sec>
      <sec id="sec-2-3">
        <title>Switch</title>
        <p>id: Switch1
state: RUNNING</p>
        <p>find-insertion-pos
WWoWrokroekrrekrer wowrokwrlokorlakodla-odha-edhu-erhuiersuitrsiitcsitcic
idi:di:dC:uCbuiCbeui3bei3e3 fifnidfn-idin-ndis-neisrnetsrietorinto-inpo-onps-opsos
stsattsaett:aet:eR:URNUNRNIUNNNIGNNIGNG</p>
      </sec>
      <sec id="sec-2-4">
        <title>Switch</title>
        <p>id: Switch1
state: OFF</p>
        <p>
          RReRqeuqeeuqseutsetst
idi:di:dR:eRqeuRqeeusqetus1ets1t3
sisziesz:iez:e1:2132.1342.534.545
dedaeddaledialndieln:ien:e1:21:201:020::000:000:000
find-insertion-pos
WWorokrekrer wowrokrlkolaoda-dh-ehueruirsitsitcic
idi:d: CuCbuibei5e5 fifnidn-di-nisnesretritoino-np-opsos
stsattaet:e: OFOFFF
original model
To investigate the applicability of RACR to self-adaptive systems, we implemented
the distributed indexing of Wikipedia pages using a network of system-on-a-chip
workers [
          <xref ref-type="bibr" rid="ref9">9</xref>
          ]. These are Cubieboards having a 1 Ghz CPU, 1GB of RAM, running
Linux, and are connected to a master via switches and Ethernet links. Every
worker and switch is powered by a USB charging hub, which enables the switching
and energy measurement of individual devices.
        </p>
        <p>We developed an adaptation and two scheduling strategies, each written with
RACR. The adaptation strategy controls the number of powered on workers. Our
solution checks periodically for idle workers to be switched off while ensuring
a minimum number of online workers to secure stable performance in case of
load peaks. A round-robin scheduler always chooses the shortest queue, and a
load-consolidating scheduler tries to use as few workers as possible.</p>
        <p>The solution is evaluated in a small-scale case study, whose structure and the
scheduling of a request on it are depicted in Figure 1. To analyze our approach’s
scalability, we developed a simulation environment that simulates the execution of
tasks and their associated energy consumption based on models we acquired from
our physical use case. The simulated use case comprises 315 workers connected
via 63 switches fulfilling 4,600 requests within an hour. Figure 2 shows the power
consumption of the two scheduling strategies, using a different color for each
worker. The load-consolidating scheduler (shown at the bottom) uses 6.4% less
energy than the round-robin scheduler while using less workers.</p>
        <p>As the model can be modified with rewrites, it permits addition and removal
of workers and the exchange of scheduling and adaptation strategies during
runtime.
5</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>Conclusion and Outlook</title>
      <p>In this work, we showed the applicability of RAG-controlled rewriting for
selfadaptive systems in a distributed data processing use case. In addition, we plan
to conduct more case studies exploring the scalability and adding heterogeneity.
Another case study involves an extended runtime model with included software
structure, in which the presented concepts are applied to iteratively transform
the model to code describing a constraint problem. First measurements show
very short response times for every transformation after the initial one.</p>
      <p>In conclusion, RACR enables incremental evaluation for large runtime models
with high update rates, hence offering opportunities for the usage in adaptive,
resource aware systems, such as Big Data systems.</p>
    </sec>
    <sec id="sec-4">
      <title>Acknowledgments</title>
      <p>This work is partly supported by the German Research Foundation (DFG)
in the SFB 912 “Highly Adaptive Energy-Efficient Computing”, the cluster of
excellence cfaed, and within the Research Training Group “Role-based Software
Infrastructures for continuous-context-sensitive Systems” (GRK 1907).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          1.
          <string-name>
            <given-names>R.</given-names>
            <surname>Lemos</surname>
          </string-name>
          et al.,
          <article-title>“Software Engineering for Self-Adaptive Systems: A Second Research Roadmap,” in Software Engineering for Self-Adaptive Systems II, ser</article-title>
          . LNCS,
          <string-name>
            <given-names>R.</given-names>
            <surname>Lemos</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H.</given-names>
            <surname>Giese</surname>
          </string-name>
          ,
          <string-name>
            <given-names>H. A.</given-names>
            <surname>Müller</surname>
          </string-name>
          , and M. Shaw, Eds. Springer,
          <year>2013</year>
          , vol.
          <volume>7475</volume>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          2.
          <string-name>
            <given-names>Y.</given-names>
            <surname>Chen</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Dunfield</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M. A.</given-names>
            <surname>Hammer</surname>
          </string-name>
          , and U. A. Acar, “
          <article-title>Implicit Self-adjusting Computation for Purely Functional Programs,” in ICFP</article-title>
          . New York, NY, USA: ACM,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          3.
          <string-name>
            <given-names>J.</given-names>
            <surname>Kephart</surname>
          </string-name>
          and
          <string-name>
            <given-names>D.</given-names>
            <surname>Chess</surname>
          </string-name>
          , “
          <article-title>The vision of autonomic computing</article-title>
          ,” Computer, vol.
          <volume>36</volume>
          , no.
          <issue>1</issue>
          ,
          <string-name>
            <surname>Jan</surname>
          </string-name>
          .
          <year>2003</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          4.
          <string-name>
            <given-names>G.</given-names>
            <surname>Blair</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Bencomo</surname>
          </string-name>
          , and R. B. France, “Models@run.time,” Computer, vol.
          <volume>42</volume>
          , no.
          <issue>10</issue>
          ,
          <string-name>
            <surname>Oct</surname>
          </string-name>
          .
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          5.
          <string-name>
            <given-names>S.</given-names>
            <surname>Götz</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Ilsche</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Cardoso</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Spillner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>T.</given-names>
            <surname>Kissinger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>U.</given-names>
            <surname>Aßmann</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W.</given-names>
            <surname>Lehner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>W. E.</given-names>
            <surname>Nagel</surname>
          </string-name>
          ,
          <article-title>and</article-title>
          <string-name>
            <given-names>A.</given-names>
            <surname>Schill</surname>
          </string-name>
          , “
          <string-name>
            <surname>Energy-Efficient Databases Using Sweet Spot Frequencies</surname>
          </string-name>
          ,”
          <source>in Proceedings of the 2014 IEEE/ACM 7th International Conference on Utility and Cloud Computing. IEEE Computer Society</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          6. G. Hedin, “Reference attributed grammars,”
          <source>Informatica (Slovenia)</source>
          , vol.
          <volume>24</volume>
          , no.
          <issue>3</issue>
          ,
          <year>2000</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          7.
          <string-name>
            <given-names>C.</given-names>
            <surname>Bürger</surname>
          </string-name>
          , “
          <article-title>Reference Attribute Grammar Controlled Graph Rewriting: Motivation &amp; Overview,” in SLE</article-title>
          . ACM,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          8.
          <string-name>
            <given-names>F.</given-names>
            <surname>Baader</surname>
          </string-name>
          and
          <string-name>
            <given-names>T.</given-names>
            <surname>Nipkow</surname>
          </string-name>
          ,
          <article-title>Term rewriting and all that</article-title>
          . Cambridge university press,
          <year>1999</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          9.
          <string-name>
            <given-names>C.</given-names>
            <surname>Bürger</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Mey</surname>
          </string-name>
          ,
          <string-name>
            <given-names>R.</given-names>
            <surname>Schöne</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Karol</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Langner</surname>
          </string-name>
          , “
          <article-title>Using Reference Attribute Grammar-Controlled Rewriting for Energy Auto-Tuning,</article-title>
          ” in 10th International Workshop on Models@run.time, Ottawa, Canada, Sep.
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>