Category: Java Performance

Does BlockingQueue.take() use CPU?

No… [root@cmhlcarchapp01 ~]# cat t.java import java.util.concurrent.*; public class t implements Runnable { static ArrayBlockingQueue Q = new ArrayBlockingQueue(5); String type; public static void main (String args[]) { t n = new t(“producer”); t n2 = new t(“consumer”); } public…

Improving batch inserts into MySQL

We had a custom class to copy data from Oracle to MySQL at AWS. It was sending each statement individually, even though we batched them. import java.sql.*; public class test { public static void main(String args[]) throws Exception { Class.forName(“com.mysql.jdbc.Driver”);…

Java garbage collection stats

jstat -gcutil -t 18987 1000 where 18987 is the java PID, and 1000 is the number of milliseconds (1 second) between samples 896794.7 0.00 0.00 4.01 5.63 98.94 9259 282.051 250 336.211 618.262 896795.7 0.00 0.00 5.31 5.63 98.94 9259…

Predict full CMS collection

((heap * cms fraction) – current heap used (young and tenured)) / growth rate = prediction Sample data from GC log… : 4499906K->310178K(4718592K), 0.2461130 secs] 10382742K->6214227K(12058624K), 0.2469460 secs] [Times: user=2.77 sys=0.03, real=0.25 secs] 2016-10-25T09:41:02.431-0400: 48708.056: [GC 48708.056: [ParNew48708.198: [SoftReference, 0…

Getting memory by thread

This is not perfect, as the heap is shared. However, the documentation indicates that a ThreadMXBean can calculate how much is in use by each. The idea behind this would be to either instrument your code, or use byte code…