RSS feed [root] /weblog /java



title search:


Sun Dec 14 09:36:42 HKT 2014


(google search) (amazon search)
download zip of files only

Wed Oct 14 12:11:16 HKT 2020 From /weblog/java/libraries

high performance

Reactor framework, base on disruptor -

One http library to consider, Comsat -

disruptor 高性能队列最佳选择 -

Babl High-Performance WebSocket Server -[..]l-high-performance-websocket-server.html

(google search) (amazon search)

Thu Oct 08 08:22:27 HKT 2020 From /weblog/java/features


Invoking Assembly Language Programs using java native interface -

Best practices for using the Java Native Interface -

Other library try to simple using native library -

(google search) (amazon search)

Wed Oct 07 21:52:51 HKT 2020 From /weblog/java/features


Introduction of Lambdas expression in Java - , an example show how lambdas help to clean up the duplication -[..]mplifying-readwritelock-with-java-8.html

Another article about Java8 change, where Lambdas is the highlight -

Nice tutorial -

Huge list of articles -

Use lambdas to replace for-loop -[..]creating-your-own-loop-structure-in.html

Overview for new Date/Time library -[..]/02/java-date-time-timezone-formats.html[..]om/2014/05/java-8-features-tutorial.html

Grouping and partitioning with stream -[..]/11/java-8-streams-api-grouping-and.html
In a nutshell, make sure to never override a default method in another interface -[..]va-8-default-methods-can-break-your.html

Convert SQL feature to stream -[..]and-their-equivalents-in-java-8-streams/

Simple overview of steam operation -[..]va-8-stream-intermediate-operations.html

Behind the scenes: How do lambda expressions really work in Java? -[..]o-lambda-expressions-really-work-in-java

(google search) (amazon search)

Wed Oct 07 21:11:17 HKT 2020 From /weblog/java/features


(google search) (amazon search)

Wed Aug 26 14:25:14 HKT 2020 From /weblog/java/features


Good : dynamic, generic
Bad: slow, don't work with Obfuscators and most searching and refactoring tools

A very nice tool to get parameter name - (e.g.: user of getUser(User user))

How to improve the performance -[..]-reflection-as-fast-as-direct-calls.html

The problem of using reflection to modify final field -[..]7-writing-to-final-fields-via-reflection

Using reflection for using test -[..]f-hacking-enums-and-modifying-final.html

Sharing about using invokedynamic -[..]ticles/Invokedynamic-Javas-secret-weapon

LamdbaMetafactory is pretty fast. (*) -[..]8/01/09/JavaReflectionButMuchFaster.html

(google search) (amazon search)

Wed Jul 29 14:13:02 HKT 2020 From /weblog/java/performance


Will you get any performance improvement if you manage memory yourself? -[..]ne-is-faster-java-heap-or-native-memory/

More heap, GC will get slower -[..]ing-heap-size-beware-of-the-cobra-effect

Collection of tools to analysis GC activities -

Another presentation of performance hint for hotspot or memory -

Show how to enable and analyze the verbose:gc out data -[..]3/01/java-verbose-gc-tutorial-video.html

Discussion and comparison of difference GC at Java 1.7 -[..]7/java-garbage-collection-distilled.html . And here is the detail experiment among those difference GC, look like G1 is quite promising -[..]ng-and-benchmarking-java-7s-garbage.html

Memory is not allocate to single block, thus even you allocate enough memory in term of size, it may not enough to held individual object -

Introduction to metaspace -[..]optimising-memory-consumption-first.html

Some comments about System.gc() -[..]om/2015/12/why-i-dont-like-systemgc.html[..]ng-your-java-garbage-collection-overhead

Logging stop-the-world pauses in JVM -[..]log/logging-stop-the-world-pauses-in-jvm

Why we should put difference app in same VM -[..]0/generational-disparity-in-garbage.html

Atlassian GC tuning guide -[..]ollection-gc-tuning-guide-461504616.html

Using jemalloc to get to the bottom of a memory leak -[..]c-to-get-to-the-bottom-of-a-memory-leak/

Troubleshooting-Java-Memory-Issues -

Useful parameters for OOME -

Why Java's TLABs are so important and why write contention is a performance killer in multicore environments -

MMU gang wars: the TLB drive-by shootdown -

Latency implications of virtual memory -

foreign-memaccess -[..]cimadamore/panama/foreign-memaccess.html

(google search) (amazon search)

Tue Jul 14 14:44:05 HKT 2020 From /weblog/java/fundamental


We can control how the default hashcode return, and and what the difference of default hashcode between java7 and 8 -

(google search) (amazon search)

Tue Jul 14 10:37:55 HKT 2020 From /weblog/java/tools


Understanding Apache Maven – The Series -[..]0/understanding-apache-maven-the-series/

(google search) (amazon search)

Tue Jun 09 00:02:20 HKT 2020 From /weblog/java/discussion


(google search) (amazon search)

Wed Jun 03 15:55:56 HKT 2020 From /weblog/java/discussion


How to write a (toy) JVM -

(google search) (amazon search)

Tue Jun 02 17:50:40 HKT 2020 From /weblog/java/fundamental


Some overview articles -[..]/2011/04/garbage-collection-in-java.html[..]10/01/garbage-collection-references.html[..]work/java/javase/gc-tuning-6-140523.html[..]derstand-classic-java-garbage-collection

Interview with Azul, about the pauseless GC -

A story of how to tune GC -

NewRatio ( XX:MaxNewSize ) is important, but usually ignored -[..]ector/entry/the_second_most_important_gc

Java memory configuration and monitoring -[..]ry-configuration-and-monitoring-3rd-act/

How Garbage Collection differs in the three big JVMs -[..]ollection-differs-in-the-three-big-jvms/

Garbage Collection Bootcamp 1.0 -[..]1/03/27/garbage-collection-bootcamp-1-0/[..]ollection-interview-question-answer.html

How CMS work -[..]thecollector/entry/hey_joe_phases_of_cms

Compare between difference VM -[..]IsTheFastestGarbageCollectorInJava8.html

GC handbook -

Check what GC you are using -[..]16/04/determining-garbage-collector.html

About G1 Java Garbage Collector -[..]G1-Java-Garbage-Collector.html&Itemid=29

Tools to visualize GC -

Visualizing difference algorithm -[..]sualizing-garbage-collection-algorithms/

safepoints -

Few new GCs for huge heap -

Objects are allocated with extra space for an indirection pointer. When the Java threads access the object, they first read the indirection pointer to see whether the object has moved. When the garbage collector moves an object, it updates the indirection pointer to point to the new location. New objects are allocated with an indirection pointer that points to themselves. Only when an object is copied during GC will the indirection pointer point to somewhere else. -[..]agazine/understanding-garbage-collectors

JVM Pauses - It's more than GC -

(google search) (amazon search)

Tue Jun 02 10:14:53 HKT 2020 From /weblog/java/fundamental


Detailed decision of arraylist and linkedlist, consist of a lot benchmark results, take a look if interested:

One bug from java HashMap explaining it can be difficult to achieve fail-fast -

Performance difference of difference collection -[..]0/12/what-is-faster-jvm-performance.html[..]/2011/07/14/java-collection-performance/

A treelist implementation -

Implement LRU cache using LinkedHashMap -[..]11/06/java-secret-lru-cache-in-java.html

Problem of using soft-reference for automate cache clean up -[..]

if it claims that an element is contained in it, this might be in error, but if it claims that an element is not contained in it, then this is definitely true. -

Comment of various collections library -

List of FAQ of Java collections -[..]lections-interview-questions-and-answers

Java Collections – Performance (Time Complexity) -[..]1/java-collections-performance-time.html

Performance improvement for HashMap for Java8 -[..]hashmap-performance-improvements-in.html

Introduction to GS collection -[..]s/gs-collections-examples-tutorial-part1[..]s/gs-collections-examples-tutorial-part2

removeEldestEntry, interesting function of linkedhashmap -[..]/prevent-your-caches-from-exploding.html

How new version of java help immutable style -

(google search) (amazon search)

Tue Jun 02 10:14:05 HKT 2020 From /weblog/java/libraries


Efficient Java Matrix Library (EJML) is a linear algebra library for manipulating real/complex/dense/sparse matrices. Its design goals are; 1) to be as computationally and memory efficient as possible for both small and large matrices, and 2) to be accessible to both novices and experts. These goals are accomplished by dynamically selecting the best algorithms to use at runtime, clean API, and multiple interfaces. EJML is free, written in 100% Java and has been released under an Apache v2.0 license. -

(google search) (amazon search)

Tue Jun 02 08:32:20 HKT 2020 From /weblog/java/features


JDK 14 Foreign-Memory Access API Overview -[..]-memory-access-api-overview-70951fe221c9

Pattern Matching for instanceof in Java 14 -[..]ttern-matching-for-instanceof-in-java-14

(google search) (amazon search)

Tue Jun 02 08:30:26 HKT 2020 From /weblog/java/features


The infamous sun.misc.Unsafe explained: object creation, native memory allocation, native concurrency -

Features that help for writing low latency application -[..]1/sunmiscunsafe-and-off-heap-memory.html

Tips of using unsafe -[..]

An overview of it -[..]A-Post-Apocalyptic-sun.misc.Unsafe-World[..]ine/the-unsafe-class-unsafe-at-any-speed

(google search) (amazon search)

Tue Jun 02 08:28:50 HKT 2020 From /weblog/java/features


Watch service, watch if directory changed -

Tips of using bytebuffer -[..]2/14/the-java-bytebuffer-a-crash-course/

path : ..\.\Java.txt
absolute path : C:\Users\WINDOWS 8\workspace\Demo\..\.\Java.txt
canonical path : C:\Users\WINDOWS 8\workspace\Java.txt

Read more:[..]getcanonicalpath-java.html#ixzz3A8Zya6YG

Jump to a position of a file, inputstream.skip() is faster than reader.skip(), and reader.skip() is faster than randomAccessFile.

Java & Files: An Introduction -

(google search) (amazon search)

Fri May 01 09:13:26 HKT 2020 From /weblog/java/performance


A case showing java is faster than C++ -[..]mgroups#!topic/comp.lang.c++/7aNw3PzPvMI

Case show how to improve GC time spend on a java application -[..]11/java-vm-beware-of-younggen-space.html

A case study of solving thread contention -[..]fighting-thread-contention-in-your-code/[..]-of-java-application-performance-tuning/

Notes about measuring map performance -[..]ronicle-map-and-yahoo-cloud-service.html

High Performance Java - Binary instead of Objects - John Davies -

jemalloc, look like a really nice tool -[..]c-to-get-to-the-bottom-of-a-memory-leak/

story of finding why there is so many GC -[..]horough-jvm-thorough-analysis-ygc-part01

GC thread blocked by system call -

We always need benchmark -[..]2017/06/15/forward-vs-backward-loop.html

Investigation and solutions of performance issue caused by GC log -[..]c-pauses-caused-by-background-io-traffic

Using jemalloc to get to the bottom of a memory leak -[..]c-to-get-to-the-bottom-of-a-memory-leak/

Parallel Collection Processing: Leveraging Batching -

Maybe good to careful about collection initalization -[..]ars-with-a-single-character-code-change/

Issue of using non-thread safe collection in multi-thread -[..]oting-cpu-spike-in-a-major-trading-appli

Performance comparison of difference JVM vendor -[..]stopping_openj9_from_overtaking_hotspot/

(google search) (amazon search)

Mon Apr 06 21:51:19 HKT 2020 From /weblog/java/network


(google search) (amazon search)

Sun Mar 29 18:15:44 HKT 2020 From /weblog/java/concurrency


Even though

private List synchList = Collections.synchronizedList(new LinkedList());

is thread safe, serialize sync List is NOT thread safe for sure. The story is, if you only synchronized the collection, and if we try to get the iterator in concurrent access environment, it will throws currencymodificationexception .

For collection is small, may be making defensive copy is good. Otherwise, in java5, there is concurrency collection.


Map operation, include use of FutureTask and putIfAbsent() method from ConcurrentMap. -

Other then lterate through the elements, adding and removing elements can also be problem, this article document a few good cases about that -[..]en-a-synchronized-class-isnt-threadsafe/

Samples of using Queue.drainTo() -[..]rforming-fixed-amounts-of-work-with.html

Overview of blockingqueue -[..]/java-util-concurrent/blockingqueue.html

Simple benchmark -[..]jvm-performance-part-iii-concurrent.html

Multi-thread behaviour -[..]hread-safety-issues-with-vector-and.html

java.util.concurrent.ConcurrentHashMap VS openhft.collections.SharedHashMap -[..]autilconcurrentconcurrenthashmap-vs.html

Why are there so many concurrent queues implementations in Java? -

Why hashmap is not thread safe -[..]a-HashMap-is-considered-as-thread-unsafe

(google search) (amazon search)

Sat Feb 29 23:23:24 HKT 2020 From /weblog/java/fundamental


From java code to java heap, detail of how java use memory -[..]rks/java/library/j-codetoheap/index.html

Algorithm of determine suitable thread pool size -[..]reading-stories-about-robust-thread.html

Detail of how to analysis how much memory you need -[..]m/2012/12/how-much-memory-do-i-need.html

Chinese introduction of memory model -

Difference between PermGem and MetaSpace -[..]02/java-8-from-permgen-to-metaspace.html

How many bytes a boolean value takes in Java? -[..]many-bytes-a-boolean-value-takes-in-Java

(google search) (amazon search)

Sun Feb 16 21:39:18 HKT 2020 From /weblog/java/performance

option list

-XX:+PerfDisableSharedMem , prevent locking by sharedmem in linux -

How linkedin turn the GC -[..]ughput-and-low-latency-java-applications

Using generational & concurrent GC collector -[..]/04/ibm-jvm-tuning-gencon-gc-policy.html

Full VM option list :, update for Java7 -[..][..]ost-complete-list-of-xx-options-for.html

A simplified list for some frequency use options -[..]rbage-collector-guidelines-and-tips.html

HotSpot JVM garbage collection options cheat sheet -[..]spot-jvm-garbage-collection-options.html[..]va/javase/tech/vmoptions-jsp-140102.html

An example and story about effect of difference VM parameter affecting the performance -

Clear the code cache automatically with -XX:+UseCodeCacheFlushing -[..]time-for-long-running-java-applications/

Discussion about -XX:MinHeapFreeRatio parameter -[..]

The other detailed guide for VM parameters tuning -

Here is a more simple cookbook -

A outdated (1.4) , compehensive but still not really too detailed, overview of various GC tuning -

Some say following VM parameter is good enough
-server -Xmx -XX:+UseParallelGC[..]/page/binublog?entry=java_tuning_for_xml

Some say is useful if you have huge memory

Some say below parameter keep GC in low pause
Some say below parameter are very optimal
-XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:NewSize=1200m -XX:SurvivorRatio=16[..]d.tss?thread_id=41258&ASRC=EM_NNL_347804
Some say those parameter is good

Just in case anyone is curious, the flags enabled by -XX:+AggressiveOpts in JDK 1.6.0_25 are:


Generate dump with OOME - -XX:+HeapDumpOnOutOfMemoryError

GC log sample of -XX:+UseConcMarkSweepGC -XX:PrintFLSStatistics=1 -XX:+PrintGCDetails -

A case study of tuning VM GC parameters -[..]ld-you-trust-the-default-settings-in-jvm

Explanation for few performance related VM parameters -[..]ine-options-jvm-performance-improvement/

Show the exact vm flag that java using -[..]/looking-inside-a-jvm-xxprintflagsfinal/

For G1GC -[..]e-first-garbage-collector-tuning-flags-1[..]otspot-jvm-performance-tuning-guidelines

(google search) (amazon search)