From Agentgroup
Jump to: navigation, search

Thread migration with Mobile JikesRVM

Mobile JikesRVM <bibref>QuitadamoPhd08</bibref> is an enhanced JVM-based migration system, built on top of the IBM Jikes Research Virtual Machine. With respect to other thread migration systems (often based on interpreted or old JVMs), Mobile JikesRVM builds on a modern JIT (Just-In-Time) compiled JVM, with performance comparable to production JVMs (see DaCapo Benchmark regression tests). Thread migration in Mobile JikesRVM is implemented without any code instrumenting or stack tracking activities, parallel to the thread execution. The execution state of Java methods is calculated during JIT compilation; special frame maps are produced at this time, to be used when migration is triggered on a certain thread. Thread migration in Mobile JikesRVM is conceptually depicted in Figure 1 and Figure 2.

Thread Serialization.png

Figure 1. Thread serialization in Mobile JikesRVM

As it is evident, this framework provides the programmer with an easy thread migration API that is inspired by the Java Serialization API: thread capture (Figure 1) becomes nothing more than serializing the Thread object to a stream (e.g. socket, file) and thread restoration is accomplished by reading a Thread object from an input stream (Figure 2). The actual process of capturing the execution state is completely transparent to the programmer. Any Java Thread can be captured through this mechanism. In order to safely interrupt thread execution and prepare for migration, Mobile JikesRVM introduces migration points<bibref>Quitadamo2008</bibref>. Such points are a subset of JikesRVM scheduler’s yieldpoints and, when taken by the thread code, will trigger the self-capture phase depicted at step 3 in Figure 1. Each frame in the call stack is captured into a VM_MobileFrame object, thanks to a special VM_FrameExtractor component. The latter is capable of rapidly capturing frames compiled with the baseline and the optimized compiler, exploiting the above mention frame maps from the JIT compiler.

Thread Deserialization.png

Figure 2. Thread deserialization in Mobile JikesRVM

After the target thread and its referenced objects have been successfully checkpointed to a stream, the whole state can be re-established on another machine. Thread restoration (as in Figure 2) is realized by creating a new Thread object in the destination JVM and initializing it with the captured frames. The latter task is carried out in the Mobile JikesRVM by the VM_FrameInstaller component, which is able to rebuild the physical call stack by means of special self-installing method prologues. When starting such re-established threads, the execution flow traverses the chain of self-installing prologues (like in a fast-forward play of the past execution flow) after which execution continues normally from the last executed instruction.

The final outcome is that the thread’s execution is temporarily suspended on the original JVM, migrated, and resumed in the destination JVM.

Mobile JikesRVM has been specifically designed to deal with continuous and fast thread capture and restoration cycles, which is exactly what the PIM model needs the most.