Skip to content

Instantly share code, notes, and snippets.

Avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / log1
Created Jul 14, 2011
analyzing an endless loop problem caused by concurrent access to HashMap.get()
View log1
$ top -H
...
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
19115 root 25 0 576m 217m 9432 R 99.7 5.3 1357:12 java
28347 root 25 0 576m 217m 9432 R 99.7 5.3 1191:05 java
26912 root 25 0 576m 217m 9432 R 99.3 5.3 114:58.57 java
5607 root 25 0 576m 217m 9432 R 99.0 5.3 54:49.02 java
@rednaxelafx
rednaxelafx / DumpClassURL.java
Created Dec 7, 2011
Using the ProtectionDomain of an InstanceKlass to see where it was loaded from, with Attach API this time
View DumpClassURL.java
import java.lang.instrument.Instrumentation;
import java.net.URL;
import java.security.CodeSource;
import java.security.ProtectionDomain;
import java.util.Arrays;
import java.util.Comparator;
public class DumpClassURL {
public static void agentmain(String agentArgs, Instrumentation inst) {
Class<?>[] classes = inst.getAllLoadedClasses();
View Demo$$Lambda$1.javap
$ javap -verbose -c -s -l -private Demo\$\$Lambda\$1
Classfile /private/tmp/Demo$$Lambda$1.class
Last modified Oct 12, 2016; size 754 bytes
MD5 checksum 81ce9dafbca34417b2dfa94f596a85a1
final class Demo$$Lambda$1 implements org.apache.spark.api.java.function.VoidFunction
minor version: 0
major version: 52
flags: ACC_FINAL, ACC_SUPER, ACC_SYNTHETIC
Constant pool:
#1 = Utf8 Demo$$Lambda$1
@rednaxelafx
rednaxelafx / PrintThreadIds.java
Created Feb 25, 2011
find out the correspondence between the tid/nid of Java threads as shown from jstack/JMX, on HotSpot/Linux
View PrintThreadIds.java
package fx.jvm.hotspot.tools;
import java.util.List;
import sun.jvm.hotspot.tools.Tool;
public class PrintThreadIds extends Tool {
public static void main(String[] args) {
PrintThreadIds tool = new PrintThreadIds();
tool.start(args);
@rednaxelafx
rednaxelafx / .hotspot_compiler
Created Mar 6, 2012
Example (XS) of adding an intrinsic method to HotSpot C2. Patch against HS20-b12
View .hotspot_compiler
exclude Main main
dontinline Main doTest
compileonly Main doTest
compileonly FxIntrinsics *
@rednaxelafx
rednaxelafx / HelloWorld.java
Created May 16, 2012
Print the list of invoked methods
View HelloWorld.java
public class HelloWorld {
private static int foo() {
return 42;
}
private static void bar() {
}
public static void main(String[] args) throws Exception {
foo();
@rednaxelafx
rednaxelafx / gist:925323
Last active Jul 2, 2020
Correspondence between Sun/Oracle JDK, OpenJDK and HotSpot VM versions
View gist:925323

Correspondence between Sun/Oracle JDK, OpenJDK and HotSpot VM versions

build date Sun/Oracle JDK Version OpenJDK Version HotSpot VM Version
2006-11-29 1.6.0-b105 1.6.0-b105
2007-03-14 1.6.0_01-b06 1.6.0_01-b06
2007-06-22 1.6.0_02-b05 1.6.0_02-b05
2007-09-24 1.6.0_03-b05 1.6.0_03-b05
2007-12-14 1.6.0_04-b12 10.0-b19
@rednaxelafx
rednaxelafx / Bar$$$Lambda$101.class.javap
Last active Jun 11, 2020
Example comparison of inner-class anonfunc in Scala 2.11 vs indylambda in Scala 2.12, and how that affects Apache Spark's ClosureCleaner
View Bar$$$Lambda$101.class.javap
# LMF class generated at runtime, dumped via
# <Scala 2.12.2>/bin/scala -cp . -Djdk.internal.lambda.dumpProxyClasses=dumpclasses Bar
$ javap -verbose -private -c -s -l 'Bar$$$Lambda$101.class'
Classfile /private/tmp/dumpclasses/Bar$$$Lambda$101.class
Last modified Apr 30, 2020; size 695 bytes
MD5 checksum 419f2634b1acdf7f40ba0bb7c22eabf4
final class Bar$$$Lambda$101 implements scala.runtime.java8.JFunction0$mcV$sp,scala.Serializable
minor version: 0
major version: 52
@rednaxelafx
rednaxelafx / TestVec.java
Created Feb 9, 2015
Simple demo of autovectorization in Oracle JDK8u25 on Linux/x64 with AVX
View TestVec.java
import java.util.*;
public class TestVec {
public static int[] doTest(int[] xs, int[] ys) {
if (xs.length != ys.length) return null;
int[] zs = new int[xs.length];
for (int i = 0; i < xs.length; i++) {
zs[i] = xs[i] * ys[i];
}
return zs;
@rednaxelafx
rednaxelafx / gist:998018
Created May 29, 2011
Example of /proc/{pid}/maps and pmap -x of a groovysh process on Ubuntu 10.10 x64
View gist:998018
rednaxelafx@fx-laptop:~$ jps
7013 Jps
6946 GroovyStarter
rednaxelafx@fx-laptop:~$ cd /proc/6946
rednaxelafx@fx-laptop:/proc/6946$ ls
attr cpuset latency mountstats root statm
auxv cwd limits net sched status
cgroup environ loginuid numa_maps schedstat syscall
clear_refs exe maps oom_adj sessionid task
cmdline fd mem oom_score smaps wchan