Skip to content

Instantly share code, notes, and snippets.

View melix's full-sized avatar

Cédric Champeau melix

View GitHub Profile
@melix
melix / README.md
Last active June 22, 2023 20:57
Reproducing the benchmarks of the Maven vs Gradle performance page

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:

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) {
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
@melix
melix / Support_for_String_&toUpperCase_method_closures.patch
Created September 14, 2015 08:55
Support for instance method references
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;
@melix
melix / Support_for_String_&toUpperCase_method_closures.patch
Created September 14, 2015 08:55
Support for instance method references
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;
@melix
melix / Support_for_String_&toUpperCase_method_closures.patch
Created September 14, 2015 08:55
Support for instance method references
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;

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 class org.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).

@melix
melix / Rethrow.java
Created May 7, 2015 07:58
Dirty exception rethrow
import sun.misc.Unsafe;
import java.lang.reflect.Field;
public class Beurk {
private final static Unsafe UNSAFE;
static {
Unsafe unsafe = null;
try {
@melix
melix / build.gradle
Created April 17, 2015 20:14
Alternate build.gradle file for model-class-benchmark to test Groovy snapshot
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:0.11.91.1'
}
}
plugins {
@melix
melix / gitzip.gradle
Created March 12, 2015 13:01
Create a zip file that only includes files in Git
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)