Skip to content

Instantly share code, notes, and snippets.

View serkan-ozal's full-sized avatar

Serkan ÖZAL serkan-ozal

View GitHub Profile
@serkan-ozal
serkan-ozal / gist:4b073a9ed6ecdacc2354
Created August 23, 2014 08:48
Integer comparison
/**
* Compares two integers by considering their signs.
*
* Suppose that
* i1 = -500.000.000
* i2 = 2.000.000.000
*
* Normally "i1 < i2", but if we use "i1 - i2" for comparison
* i1 - i2 = -500.000.000 - 2.000.000.000 and we may accept result as "-2.500.000.000".
* But the actual result is "1.794.967.296" because of overflow between
@serkan-ozal
serkan-ozal / gist:06b1849e8b5654336c29
Created September 20, 2014 14:25
Rebellabs Article 2 - Java OffHeap Memory Initial Benchmark Results
Benchmark (workerType) Mode Samples Score Score error Units
===============================================================================================================================
c.z.r.o.a.OffHeapBenchmarkRunner.run DIRECT BYTE BUFFER BASED OFFHEAP thrpt 10 5.912 0.060 ops/s
c.z.r.o.a.OffHeapBenchmarkRunner.run MEMORY MAPPED FILE BASED OFFHEAP thrpt 10 1.165 0.038 ops/s
c.z.r.o.a.OffHeapBenchmarkRunner.run UNSAFE BASED OFFHEAP thrpt 10 11.467 0.500 ops/s
c.z.r.o.a.OffHeapBenchmarkRunner.run PROXY ON UNSAFE BASED OFFHEAP thrpt 10 12.932 0.106 ops/s
c.z.r.o.a.OffHeapBenchmarkRunner.run SERIALIZATION/DESERIALIZATION BASED OFFHEAP thrpt 10 0.427 0.005 ops/s
@serkan-ozal
serkan-ozal / gist:834e10c0b4c38d35c4fa
Last active August 29, 2015 14:07
JVM HIDDEN NATIVE CONTANTS, TYPES AND FIELDS
*** INT CONSTANTS ***
=====================
CardTableModRefBS::clean_card
SAVED_ON_ENTRY_REG_COUNT
Generation::GenGrain
REG_COUNT
Location::in_register
Deoptimization::Reason_unhandled
Location::OFFSET_SHIFT
_thread_in_Java
@serkan-ozal
serkan-ozal / gist:4b88aa21254c586bae50
Last active August 29, 2015 14:08
A piece of code from Jillegal 3.0 to instrument all non-primitive field assignments in OffHeap object
protected <T> void instrumentNonPrimitiveFieldAssignments(final Class<T> elementType) {
try {
Jillegal.init();
final InstrumentService instrumenterService = InstrumentServiceFactory.getInstrumentService();
final String ownerClassDesc = elementType.getName().replace(".", "/");
final Set<String> ownerClassDescSet = new HashSet<String>();
ownerClassDescSet.add(ownerClassDesc);
@serkan-ozal
serkan-ozal / gist:c1ab5ccad7bec94112a6
Last active August 29, 2015 14:09
Hotspot JVM aware serviceability agent classloader that uses a composite "sa-jdi.jar" contains all Java 6/7/8 sa-jdi jar contents at seperated directories
/**
* @author SERKAN OZAL
*
* E-Mail: <a href="mailto:serkanozal86@hotmail.com">serkanozal86@hotmail.com</a>
* GitHub: <a>https://github.com/serkan-ozal</a>
*/
package tr.com.serkanozal.jillegal.util.compressedoops.hotspot;
import java.io.File;
@serkan-ozal
serkan-ozal / gist:7daca297fd79b2d1a32e
Last active August 29, 2015 14:09
Hotspot serviceability agent based compressed-oops mode finder that attaches to current JVM process as different process to get information
/**
* @author SERKAN OZAL
*
* E-Mail: <a href="mailto:serkanozal86@hotmail.com">serkanozal86@hotmail.com</a>
* GitHub: <a>https://github.com/serkan-ozal</a>
*/
package tr.com.serkanozal.jillegal.util.compressedoops.hotspot;
import java.io.BufferedReader;
@Test
public void testToFindEntryCountFactor() {
final ICache cache = createCache();
final Random random = new Random();
final int size = 1000;
for (int i = 0; i < size; i++) {
cache.put(i, random.nextInt(size));
}
///////////////////////////////////////////////////////////////////////////////////
@serkan-ozal
serkan-ozal / gist:df914075cdadb3ade201
Last active August 29, 2015 14:11
GC Logs of Jillegal 3.0 Run During 5 Hours with HeapFragger by Billions of OffHeap and Heap Object Allocate/Deallocate/Put/Replace/Remove on JDK 8 CMS Collector [To Show Not Fail While GC]
[GC (Allocation Failure) [ParNew: 1024K->128K(1152K), 0.0045841 secs] 1024K->580K(130944K), 0.0046469 secs] [Times: user=0.08 sys=0.00, real=0.01 secs]
[Full GC (System.gc()) [CMS: 452K->742K(129792K), 0.0121245 secs] 1397K->742K(130944K), [Metaspace: 2923K->2923K(8192K)], 0.0123696 secs] [Times: user=0.00 sys=0.01, real=0.01 secs]
[GC (Allocation Failure) [ParNew: 52032K->6464K(58496K), 0.1298396 secs] 52774K->31614K(188288K), 0.1298890 secs] [Times: user=0.76 sys=0.00, real=0.13 secs]
[GC (Allocation Failure) [ParNew: 58496K->4347K(58496K), 0.0302702 secs] 83646K->37130K(188288K), 0.0303337 secs] [Times: user=0.11 sys=0.00, real=0.03 secs]
*********************************************************************
* Jillegal by Serkan OZAL (https://github.com/serkan-ozal/jillegal) *
*********************************************************************
JVM Name : Java HotSpot(TM) 64-Bit Server VM
@serkan-ozal
serkan-ozal / gist:a1ea7155d76016ccb262
Last active August 29, 2015 14:11
GC Logs of Jillegal 3.0 Run During 4 Hours with HeapFragger by Billions of OffHeap and Heap Object Allocate/Deallocate/Put/Replace/Remove on JDK 8 G1 Collector [To Show Not Fail While GC]
[Full GC (System.gc()) 1849K->741K(8192K), 0.0172398 secs]
[Eden: 2048.0K(24.0M)->0.0B(4096.0K) Survivors: 0.0B->0.0B Heap: 1849.8K(128.0M)->741.0K(8192.0K)], [Metaspace: 2923K->2923K(8192K)]
[Times: user=0.00 sys=0.02, real=0.02 secs]
[GC pause (G1 Evacuation Pause) (young), 0.0023995 secs]
[Parallel Time: 1.6 ms, GC Workers: 8]
[GC Worker Start (ms): Min: 389.9, Avg: 390.3, Max: 391.4, Diff: 1.5]
[Ext Root Scanning (ms): Min: 0.0, Avg: 0.3, Max: 1.4, Diff: 1.4, Sum: 2.8]
[Update RS (ms): Min: 0.0, Avg: 0.0, Max: 0.2, Diff: 0.2, Sum: 0.2]
[Processed Buffers: Min: 0, Avg: 0.3, Max: 1, Diff: 1, Sum: 2]
[Scan RS (ms): Min: 0.0, Avg: 0.0, Max: 0.0, Diff: 0.0, Sum: 0.0]
@serkan-ozal
serkan-ozal / gist:0b43efb4416b5741e623
Created December 22, 2014 09:38
GC Logs of Jillegal 3.0 Run During 6 Hours with HeapFragger by Billions of OffHeap and Heap Object Allocate/Deallocate/Put/Replace/Remove on JDK 8 Serial Collector [To Show Not Fail While GC]
This file has been truncated, but you can view the full file.
[GC (Allocation Failure) [DefNew: 1024K->127K(1152K), 0.0020101 secs] 1024K->560K(130944K), 0.0020595 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[Full GC (System.gc()) [Tenured: 433K->742K(129792K), 0.0026369 secs] 1376K->742K(130944K), [Metaspace: 2923K->2923K(8192K)], 0.0028236 secs] [Times: user=0.00 sys=0.00, real=0.00 secs]
[GC (Allocation Failure) [DefNew: 52032K->6463K(58496K), 0.0792648 secs] 52774K->30430K(188288K), 0.0794149 secs] [Times: user=0.05 sys=0.03, real=0.08 secs]
[GC (Allocation Failure) [DefNew: 58495K->139K(58496K), 0.0398059 secs] 82462K->30549K(188288K), 0.0398695 secs] [Times: user=0.05 sys=0.00, real=0.04 secs]
*********************************************************************
* Jillegal by Serkan OZAL (https://github.com/serkan-ozal/jillegal) *
*********************************************************************
JVM Name : Java HotSpot(TM) 64-Bit Server VM