4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
4th International Conference on Principles and Practices ... - MADOC
You also want an ePaper? Increase the reach of your titles
YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.
A str<strong>on</strong>gly mobile thread has the ability to migrate its code <strong>and</strong><br />
executi<strong>on</strong> state, including the program counter, saved processor<br />
registers, return addresses <strong>and</strong> local variables. The comp<strong>on</strong>ent is<br />
suspended, marshaled, transmitted, unmarshaled <strong>and</strong> then<br />
restarted at the destinati<strong>on</strong> node without loss of data or executi<strong>on</strong><br />
state. Str<strong>on</strong>g mobility turns out to be far more powerful where<br />
complex distributed computati<strong>on</strong>s are required, as it preserves the<br />
traditi<strong>on</strong>al programming style of threads, without requiring any<br />
code rollback or other expedients: it reduces the migrati<strong>on</strong><br />
programming effort to the invocati<strong>on</strong> of a single operati<strong>on</strong> (e.g. a<br />
migrate() method) <strong>and</strong> leads to cleaner implementati<strong>on</strong>s.<br />
Despite these advantages, many systems support <strong>on</strong>ly weak<br />
mobility <strong>and</strong> the reas<strong>on</strong> lies mainly in the complexity issues of<br />
str<strong>on</strong>g mobility <strong>and</strong> in the insufficient support of existing JVMs to<br />
deal with the executi<strong>on</strong> state. Moreover, a weakly mobile system<br />
gives the programmer more c<strong>on</strong>trol over the amount of state that<br />
has to be transferred, while an agent using str<strong>on</strong>g migrati<strong>on</strong> may<br />
bring unnecessary state, increasing the size of the serialized data.<br />
2.3 Related work<br />
Several approaches have been proposed so far to overcome the<br />
limitati<strong>on</strong>s of the JVM as c<strong>on</strong>cerns the executi<strong>on</strong> state<br />
management. The main decisi<strong>on</strong> that each approach has to take<br />
into account is how to capture the internal state of threads,<br />
providing a fair trade-off between performances <strong>and</strong> portability.<br />
In literature, we can typically find two categories of approaches:<br />
• modifying or extending the source code of existing<br />
JVMs to introduce APIs for enabling migrati<strong>on</strong> (JVMlevel<br />
approach);<br />
• translating somehow the applicati<strong>on</strong>’s source code in<br />
order to trace c<strong>on</strong>stantly the state of each thread <strong>and</strong><br />
using the gathered informati<strong>on</strong> to rebuild the state<br />
remotely (applicati<strong>on</strong>-level approach).<br />
2.3.1 JVM-level approach<br />
The former approach is, with no doubt, more intuitive because it<br />
provides the user with an advanced versi<strong>on</strong> of the JVM, which<br />
can completely externalize the state of Java threads (for thread<br />
serializati<strong>on</strong>) <strong>and</strong> can, furthermore, initialize a thread with a<br />
particular state (for thread de-serializati<strong>on</strong>). The kind of<br />
manipulati<strong>on</strong>s made up<strong>on</strong> the JVM can be several.<br />
The first proposed projects following the JVM-level approach like<br />
Sumatra [22], Merpati [21], JavaThread [6] <strong>and</strong> NOMADS [23],<br />
extend the Java interpreter to precisely m<strong>on</strong>itor the executi<strong>on</strong><br />
state evoluti<strong>on</strong>. They, usually, face the problem of stack<br />
references collecti<strong>on</strong> modifying the interpreter in such a way that<br />
each time a bytecode instructi<strong>on</strong> pushes a value <strong>on</strong> the stack, the<br />
type of this value is determined <strong>and</strong> stored "somewhere" (e.g., in a<br />
parallel stack). The drawback of this soluti<strong>on</strong> is that it introduces<br />
a significant performance overhead <strong>on</strong> thread executi<strong>on</strong>, since<br />
additi<strong>on</strong>al computati<strong>on</strong> has to be performed in parallel with<br />
bytecode interpretati<strong>on</strong>. Other projects tried to reduce this<br />
penalizati<strong>on</strong> avoiding interpreter extensi<strong>on</strong>, but rather using JIT<br />
(Just In Time) re-compilati<strong>on</strong> (such as Jessica2 [28]) or<br />
performing type inference <strong>on</strong>ly at serializati<strong>on</strong> time (<strong>and</strong> not<br />
during thread normal executi<strong>on</strong>). In ITS [5], the bytecode of each<br />
method in the call stack is analyzed with <strong>on</strong>e pass at serializati<strong>on</strong><br />
time: the type of stacked data is retrieved <strong>and</strong> used to build a<br />
portable data structure representing the state. The main drawback<br />
of every JVM-level soluti<strong>on</strong> is that they implement special<br />
modified JVM versi<strong>on</strong>s that users have often to download;<br />
therefore they are forced to run their applicati<strong>on</strong>s <strong>on</strong> a prototypal<br />
<strong>and</strong> possibly unreliable JVM.<br />
2.3.2 Applicati<strong>on</strong>-level approach<br />
In order to address the issue of n<strong>on</strong>-portability <strong>on</strong> multiple Java<br />
envir<strong>on</strong>ments, some projects propose a soluti<strong>on</strong> at the applicati<strong>on</strong><br />
level. In these approaches, the applicati<strong>on</strong> code is filtered by a<br />
pre-processor, prior to executi<strong>on</strong>, <strong>and</strong> new statements are inserted,<br />
with the purpose of managing state capturing <strong>and</strong> restorati<strong>on</strong>.<br />
Some of these soluti<strong>on</strong>s rely <strong>on</strong> a bytecode pre-processor (e.g.<br />
JavaGoX [18] or Brakes [25]), while others provide source code<br />
translati<strong>on</strong> (e.g. Wasp [12], JavaGo [19], Wang's proposal [26]).<br />
Two of them [19, 26] hide a weak mobility system behind the<br />
appearance of a str<strong>on</strong>g mobility <strong>on</strong>e: they, in fact, re-organize<br />
"str<strong>on</strong>gly-mobile" written code into a "weakly-mobile" style, so<br />
that weak mobility can be used instead. Portability is achieved at<br />
the price of a slowdown, due to the many added statements.<br />
2.3.3 Discussi<strong>on</strong><br />
Starting from the above c<strong>on</strong>siderati<strong>on</strong>s, we have decided to design<br />
<strong>and</strong> implement a str<strong>on</strong>g thread migrati<strong>on</strong> system able to overcome<br />
many of the problems of the above-explained approaches. In<br />
particular, our framework is written entirely in Java <strong>and</strong> it does<br />
neither suffer performance overheads, due to bytecode<br />
instrumentati<strong>on</strong>s, nor reliability problems, because the user does<br />
not have to download a new, possibly untrustworthy, versi<strong>on</strong> of<br />
JikesRVM. The framework is capable of dynamically installing<br />
itself <strong>on</strong> several recent versi<strong>on</strong>s of JikesRVM (we carried out<br />
successful tests starting from release 2.3.2). In fact, every single<br />
comp<strong>on</strong>ent of the migrati<strong>on</strong> system has been designed <strong>and</strong><br />
developed to be used as a normal Java library, without requiring<br />
rebuilding or changing the VM source code. Therefore, our<br />
JikesRVM-based approach can be classified as a midway<br />
approach between the above-menti<strong>on</strong>ed JVM-level <strong>and</strong><br />
Applicati<strong>on</strong>-level approaches. Other midway approaches [14]<br />
exploit the JPDA (Java Platform Debugger Architecture) that<br />
allows debuggers to access <strong>and</strong> modify runtime informati<strong>on</strong> of<br />
running Java applicati<strong>on</strong>s. The JPDA can be used to capture <strong>and</strong><br />
restore the state of a running program, obtaining a transparent<br />
migrati<strong>on</strong> of mobile agents in Java, although it suffers from some<br />
performance degradati<strong>on</strong> due to the debugger intrusi<strong>on</strong>.<br />
3. ENABLING THREAD MIGRATION ON<br />
TOP OF JIKESRVM<br />
In this secti<strong>on</strong> we will describe how we implemented our str<strong>on</strong>g<br />
migrati<strong>on</strong> mechanism <strong>on</strong> top of the IBM Jikes Research Virtual<br />
Machine (RVM). The JikesRVM project was born in 1997 at the<br />
IBM T.J. Wats<strong>on</strong> Laboratories [1] <strong>and</strong> it has been recently<br />
d<strong>on</strong>ated by IBM to the open-source community. Two main design<br />
goals drove the development of such successful research project<br />
[2]: (i) supporting high performance Java servers; (ii) providing a<br />
flexible research platform “where novel VM ideas can be<br />
explored, tested <strong>and</strong> evaluated”.<br />
In this research virtual machine, several modern programming<br />
language techniques have been experimented <strong>and</strong>, throughout this<br />
presentati<strong>on</strong>, we will focus mainly <strong>on</strong> those features that are most<br />
strategic to our system. The proposed descripti<strong>on</strong> will follow the<br />
migrati<strong>on</strong> process in its fundamental steps, from thread state<br />
capturing to resuming at the destinati<strong>on</strong> machine.<br />
64