Skip to content

Instantly share code, notes, and snippets.

View serkan-ozal's full-sized avatar

Serkan ÖZAL serkan-ozal

View GitHub Profile
public static void putObjectAsMultiPart(String bucketName, File file, long partSize) {
AmazonS3Client s3Client =
new AmazonS3Client(
new PropertiesCredentials(IOUtil.getResourceAsStream("aws-credentials.properties"));
bucketName = preProcessBucketName(bucketName);
List<PartETag> partETags = new ArrayList<PartETag>();
List<MultiPartFileUploader> uploaders = new ArrayList<MultiPartFileUploader>();
@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:4ec4cbb128645a80ea25
Created November 8, 2014 09:19
Sample working JNI code to get address of given object, to get object at given address and pin/unpin given object to memory for not to be collected by GC
/**
* @author SERKAN OZAL
*
* E-Mail: <a href="mailto:[email protected]">[email protected]</a>
* GitHub: <a>https://github.com/serkan-ozal</a>
*/
#include <jni.h>
#include "tr_com_serkanozal_jvm_playground_MemoryUtil.h"
@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:[email protected]">[email protected]</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:[email protected]">[email protected]</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