Posts Tagged 'performance'

Java & Multicore

Recently I needed to run some very CPU intensive calculations in Java. In order to harvest the full power of my multicore machine I took a look at Java’s concurrent package. I never used this package before. Either I had some convenient third party library functions at my hand which successfully were able to hide all the multithreading stuff from me, sometimes I struggled with Thread, Runnable and synchronized statements or … I just used another language :P

So here are my results from a short trip into the adventurous realm of multicore programming in Java. To make things a little bit simpler in this post I will demonstrate to run several functions calculating a high Fibonacci number instead of using a more complicated real world example. The calculations will be distributed via a thread pool and all classes used in this example belong to the Java standard library, so there won’t be a need to install any extra packages.

Continue reading ‘Java & Multicore’

Advertisements

Displaying Disc Utilisation Information

Most Linux distributions come with a handy package called sysstat which is a collection of several different performance monitoring tools. To find processes which are consuming a lot of hard disc performance use pidstat:

 pidstat -dw

This will give you a list of all processes and their task switching activity (-w) which will include voluntary and non-voluntary context switches. Optionally you can also get I/O statistics (-d). Now look at the process you suspect to use much of the hard disc performance (i.e. grep for mysqld). A high number of voluntary context switches means, that the program waits for data to write or read (this includes all kind of data, also network data, so don’t misinterpret the numbers). If a process is constantly tries to write data to the hard disc but has a lot of voluntary context switches, the hard disc is probably overstressed which blocks the process and makes the scheduler switching to another application.
To see a summary of all I/O utilisation use:

  iostat -dmx 5

This will print every five seconds an extended (-x) utilisation statistic in megabytes (-m) about the current hard disc usage (-d). Look for the r/s or w/s column to figure out how much megabytes are read from/written to the disk per seconds.