Skip to content

Instantly share code, notes, and snippets.

View rednaxelafx's full-sized avatar

Kris Mok rednaxelafx

View GitHub Profile
@rednaxelafx
rednaxelafx / test_memset.c
Created April 21, 2011 12:29
Show x64 calling convention, demo'd with a call to memset(). GCC's memset is a builtin function, to disable it, use -fno-builtin. Refer to http://en.wikipedia.org/wiki/X86_calling_conventions#System_V_AMD64_ABI_convention
#include <string.h>
int main() {
memset(0x42, 42, 37);
return 0;
}
@rednaxelafx
rednaxelafx / .hotspotrc
Created May 2, 2011 16:15
A demo on GC performance impact differences between an int[] and an Integer[] (on 64-bit HotSpot VM, 19.0-b09)
# print out GC detail log
+PrintGCDetails
# make the GC logs simpler by disabling a scavenge before the System.gc()s
-ScavengeBeforeFullGC
# set heap size big enough to hold the array in the demo
InitialHeapSize=2g
MaxHeapSize=2g
D:\experiment>ruby -v
ruby 1.8.6 (2008-08-11 patchlevel 287) [i386-mswin32]
D:\experiment>irb
irb(main):001:0> system 'echo 123'
123
=> true
irb(main):002:0> system '@echo 123'
=> false
irb(main):003:0> quit
@rednaxelafx
rednaxelafx / CLHSDB session
Created May 5, 2011 07:52
Another demo on primitive type arrays and wrapper type arrays in a Java program running on HotSpot, using SA on a core dump. Env: JDK6u25, x64, -Xmx10m (-server and -XX:+UseCompressedOops are on by default)
$ java -version
java version "1.6.0_25"
Java(TM) SE Runtime Environment (build 1.6.0_25-b06)
Java HotSpot(TM) 64-Bit Server VM (build 20.0-b11, mixed mode)
$ alias -p | grep clhsdb
alias clhsdb='java -classpath .:$JAVA_HOME/lib/sa-jdi.jar sun.jvm.hotspot.CLHSDB'
$ clhsdb
hsdb> help
Available commands:
assert true | false
@rednaxelafx
rednaxelafx / gist:971134
Created May 13, 2011 19:20
A compilation log showing the effects of tiered system of HotSpot 20 build 11 (JDK6u25) on x64. The command used was: jconsole -J-XX:+TieredCompilation -J-XX:+PrintCompilation
56 1 3 java.lang.String::hashCode (64 bytes)
57 2 3 java.lang.String::equals (88 bytes)
--- n java.lang.System::arraycopy (static)
58 3 3 java.lang.String::charAt (33 bytes)
58 5 3 java.lang.Object::<init> (1 bytes)
58 4 3 java.lang.Math::min (11 bytes)
62 6 3 java.nio.Buffer::position (43 bytes)
62 9 3 java.nio.charset.CoderResult::isUnderflow (13 bytes)
63 7 3 java.util.jar.Attributes$Name::isValid (32 bytes)
63 8 3 java.util.jar.Attributes$Name::isAlpha (30 bytes)
@rednaxelafx
rednaxelafx / .hotspot_compiler
Created May 15, 2011 06:49
Example of code reordering from with HotSpot 20. Run on JDK6u25.
dontinline TestC2BranchPrediction conditionalBranch
dontinline TestC2BranchPrediction marker
@rednaxelafx
rednaxelafx / Make udis86
Created May 16, 2011 04:06
Use udis86 to disassemble instructions in a JVM crash log
$ wget http://prdownloads.sourceforge.net/udis86/udis86-1.7.tar.gz?download
$ tar zxvf udis86-1.7.tar.gz
$ cd udis86-1.7
$ ./configure
$ make
$ cd udcli
@rednaxelafx
rednaxelafx / .hotspotrc
Created May 18, 2011 10:35
Use JMX to make HPROF heap dumps right before and after a full GC
+PrintGCDetails
@rednaxelafx
rednaxelafx / gist:997679
Created May 29, 2011 11:45
prtstat example: using prtstat on a groovysh process on Ubuntu 10.10 x64
$ prtstat 4394
Process: java State: S (sleeping)
CPU#: 2 TTY: 136:39 Threads: 16
Process, Group and Session IDs
Process ID: 4394 Parent ID: 4341
Group ID: 4394 Session ID: 4341
T Group ID: 4394
Page Faults
This Process (minor major): 64582 18
@rednaxelafx
rednaxelafx / gist:998011
Created May 29, 2011 18:23
See the default values of various sizes set by a J9 VM, with -verbose:sizes
$ java -version
java version "1.6.0"
Java(TM) SE Runtime Environment (build pxa6460sr8fp1-20100624_01(SR8 FP1))
IBM J9 VM (build 2.4, JRE 1.6.0 IBM J9 2.4 Linux amd64-64 jvmxa6460sr8ifx-20100609_59383 (JIT enabled, AOT enabled)
J9VM - 20100609_059383
JIT - r9_20100401_15339ifx2
GC - 20100308_AA)
JCL - 20100624_01
$ java -verbose:sizes
-Xmca32K RAM class segment increment