Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: New name has been suggested

Background

Groovy has a performance problem, compared with Java, due to its dynamic nature, while there are several requests for performance improvement.

Proposed Solution

Implementing just-in-time compiler is a proper way to help boosting performance of Groovy. It would be great to have a Groovy module (in this case a JVMTI agent) to help re-compiling Groovy classes during runtime.

Implementation

GIT is a profiling-based just-in-time GJIT could be thought as a hotspot compiler for Groovy. It is able to perform data flow analysis for Groovy-compiled classes and re-define specialised version of them at run-time.
There are two main components.

The first one is a JVMTI agent to profile calls to
ScriptBytecodeAdapter.invoke* at the caller sites. The profiler then
gathers information, including Type information, from
MetaClassImpl.getMethod* to identify hot regions, with a threshold
value.

After the threshold is reached the profiler tell the optimiser thread,
the second component, to perform dataflow analysis on these hot
regions, by replacing calls to ScriptBytecodeAdapter.invoke with
direct calls (to bypass the meta-layer). Classes then re-compiled and
re-defined using the JVMTI instrumentation. (no new class created, so
PermGen not affected)

There's also a hook to detect the change of meta-class of each class.
If there's a change, the optimiser will re-store the original class
and start profiling it again.

This is an experimental release. GIT GJIT 0.3 is in its alpha-stage, and not yet ready for production use.
The binary is available here: git-all-0.3.jar
The early version of GIT GJIT is located at http://svn.codehaus.org/grails-plugins/grails-aop/trunk/MAIN/agent/

Usage

Add

Code Block
  -javaagent:gitgjit-all-0.3.jar 

to your Java command line to use GITGJIT.

Known Bugs

  • GITGJIT's optimiser thread will not stop by itself. You have to kill the process manually.