replay compilation: improving debuggability of a just-in time complier presenter: jun tao
TRANSCRIPT
Replay Compilation: Improving Debuggability of a Just-in Time Complier
Presenter: Jun Tao
Outline
• Introduction• Behavior of a Dynamic Compiler• Overview of Replay Compilation• Implementation• Experimental Results
Introduction
• Difficulties in debugging with a dynamic compiler– Static compiler• Recompile and produce diagnostic output
– Dynamic compiler• Recompilation may not work
– Non-determinism in execution order– Applied optimization might change– Runtime information: resolution status, classes hierarchy,
runtime profile
Introduction
• Reproducing the Compilation– Invoke a dynamic compiler as if it were a stand-
alone tool– Reproduce the inputs
Introduction
• Solutions: trace-and-replay– Ordering-based• Record and replay the order of synchronization events• Compiler operates deterministically• Results may change because non-deterministic input
– Content-based• Save and restore the values of the input• Generates prohibitively large amount of data• Significantly increases the execution time
Introduction
• Other Solution– First error data capture (FEDC)• Uses special hardware, firmware and software to
record information• Efficient
Introduction
• Replay JIT compilation– Content-based trace-and-replay approach– State-saving compiler• Records information into a log, which is in main
memory
– Replaying compiler• Reproduce the problem by using the system dump
– Confidence-based filtering• Only save inputs of methods that are likely to cause
errors
Behavior of a Dynamic Compiler
• Static compiler– Invoked by users– Source files– Options as command line arguments
• Dynamic compiler– A component of a virtual machine– Determines which methods to compile with what
set of options– Inputs are provided as runtime data structures
Behavior of a Dynamic Compiler
• Runtime information as inputs– System configuration data• Configuration of hardware and software• Command line options and the environment variables
– Virtual machine states• Set of classes that have been initialized• Address of the compiled optimizations• Class hierarchy of the loaded classes• Resolution statuses of external references
– Runtime profile• Runtime profiler output• Optimization level
Behavior of a Dynamic Compiler
• Variable and Fixed Inputs– Variable inputs• May change after a compilation of a method• Virtual machine status• Runtime profiles
– Fixed Inputs• Target methods• System configuration
Overview of Replay Compilation
• System Dump Based Approach– Virtual machine must be configured to generate a
system dump at crashes and user interrupts– Avoids expensive I/O– Suffices to invoke the replaying compiler with the
system dump– Replaying compiler can be invoked in a different
platform
Overview of Replay Compilation
• Log Structure– Input by data structure access• Records a pair of the address and the value into a log• Retrieve the value by using the address as a key
– Input in a function call• Records into a log the return value together with a list
of function identifier and the parameter values• Retrieves the return value by using the list as a key
– The values for fixed inputs can be saved at the time of creating the system dump
Overview of Replay Compilation• Building State-saving and Replaying Compilers
– Uses different macros, depending on input types
• Building State-saving and Replaying Compilers (continued)
• Building State-saving and Replaying Compilers (continued)
Overview of Replay Compilation
• Replaying the Compilation– User invokes the replaying compiler and specifies
method signatures or addresses of compiled code– Replay compiler load the system dump into its
address space– Adjust the address used in state-saving process• Can be avoid by restoring a system dump into the same
address as the state-saving address
Overview of Replay Compilation
• Further reducing the size of log– Compress the logs– Exploit default values– Confidence-based filtering• Increase the confidence of a method, if the method is
in heavily used libraries• Decrease the confidence of a method, if the control
flow of the method is complex
Overview of Replay Compilation
• Some other topics– We can use different set of options to narrow
down the cause of options– System dump will not include the data structures
for unloaded classes• Ignore• Store the data structure when it is unloaded
Implementation
• State-Saving Compiler– Allocates a memory area as the log for each
compilation of a method– Compresses each log– Associates each log with the address of the JIT-
compiled code
Implementation
• State-Saving Compiler (continued)– Creates an anchor structure• Markers in its header and trailer• Size• Version number of the state-saving compiler• A link list of the logs• Another pointer called current log
– Should not be accessible in the list of complete logs
Implementation
• Replaying Compiler– Restores a system dump– Scans the markers– Scans the list for the log
Experiment Results
Experiment Results
Experiment Results
Experiment Results
Experiment Results
Conclusion
• State-saving compiler saves inputs in logs• Replaying compiler gets logs from system
dump• Logs reside in main memory • Compression and filtering are used
Questions ?