View README.md

Gradle vs Maven performance reproduction instructions

Install the Gradle Profiler

This page explains how to reproduce the Gradle vs Maven performance numbers yourself. For that, you need to install the Gradle profiler, a tool which will automate benchmarking by running several builds in a row, with the appropriate options (it also runs Maven builds).

Generate the test projects

Our performance comparison uses 4 test projects:

View gist:cdb961434347056ba66207acfdb4e6c3
Structural Search Template
$ReturnType$ $Method$($ParameterType$ $Parameter$);
Found Matches in JDK (206 usages found)
Library (206 usages found)
Unclassified match (206 usages found)
/home/cchampeau/.gradle/caches/modules-2/files-2.1/net.java.dev.jna/platform/3.4.0/e3f70017be8100d3d6923f50b3d2ee17714e9c13/platform-3.4.0.jar (2 usages found)
com.sun.jna.platform.win32 (2 usages found)
W32Errors (2 usages found)
FAILED(int) (1 usage found)
19public static final boolean FAILED(int hr) {
View quicksort.groovy
import groovy.transform.CompileStatic
@CompileStatic
void swap(int[] a, int i, int j) {
int temp = a[i]
a[i] = a[j]
a[j] = temp
}
@CompileStatic
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View Support_for_String_&toUpperCase_method_closures.patch
Index: src/main/org/codehaus/groovy/runtime/MethodClosure.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Local version)
+++ src/main/org/codehaus/groovy/runtime/MethodClosure.java (revision Shelved version)
@@ -19,8 +19,8 @@
package org.codehaus.groovy.runtime;
View how-to-leak.md

If you take a look at the dump here: https://dl.dropboxusercontent.com/u/20288797/temp/memory-dump.tar.bz2

And that you look at the classes, you will see several copies of the classorg.codenarc.rule.Violationororg.codehaus.groovy.antlr.parser.GroovyLexer`. The multiple copies come from different classloaders, which is fine. What is not is that those classes are not retained anymore, nor is their classloader (they are all softly or weakly reachable), but they are not garbage collected, leading to the leak.

To reproduce the PermGen leak, first make sure you use JDK 7 or JDK 6, but the two should be tested independently because Groovy doesn't use the same way to store global class information (ClassValue since JDK 7).

View Rethrow.java
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class Beurk {
private final static Unsafe UNSAFE;
static {
Unsafe unsafe = null;
try {
View build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.91.1'
}
}
plugins {
View gitzip.gradle
task srcZip(type:Zip) {
appendix = 'gitsources'
from project.projectDir
doFirst {
Set excludeList = [relativePath(archivePath).toString()]
def p = "git status --ignored --porcelain .".execute([], project.projectDir)
def writer = new StringWriter()
p.consumeProcessOutput(writer, null)