Java performance

1,479 views

Published on

0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
1,479
On SlideShare
0
From Embeds
0
Number of Embeds
201
Actions
Shares
0
Downloads
31
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Java performance

  1. 1. Java Performance Debugging
  2. 2. Few Questions to Consider• What is expected throughput• What is expected latency• Maximum No. of concurrent users/tasks• Expected Throughput/latency at max users• Worst case latency• Tolerable GC latency
  3. 3. Bottlenecks• Memory• CPU• Disk I/O• Network I/O
  4. 4. Memory (RAM)• -Xmx too low• Process leaking memory (et tu java!)• Insufficient DirectBuffers• Insufficient PermGen space• Page thrashing
  5. 5. Memory (Contd.)• Run –XX:+HeapDumpOnOutOfMemoryError. Check .hprof files in working directory or – XX:HeapDumpPath• jmap –histo<pid>
  6. 6. Memory (contd.)• High si/so coinciding with low ‘free’ memory implies page thrashing
  7. 7. Other OutOfMemory Errors• Incorrect PermGen size –XXMaxPermSize – java.lang.OutOfMemoryError: PermGen space – jstat -gc<pid> – Can monitory ‘PU’ vs ‘PGCMX’ from jstat - gccapacity• Incorrect Direct Buffer limit - XX:MaxDirectMemorySize – java.lang.OutOfMemoryError: Direct buffer memory
  8. 8. CPU• Check Garbage collector stats – Jstat –gc<pid>• Investigate using – JMX, TOP – Using TOP get the thread ID – Thread Dump using ‘kill -3’ or ‘jstack’ – Search Hex thread id in thread dump
  9. 9. Disk I/O• Iostat %iowait<interval><samples>• High %iowait indicates I/O bottleneck• If java process is causing high I/O, check the thread dump
  10. 10. Java Heap Structure
  11. 11. Garbage Collector Choice• Serial GC (Never use this!) – -XX:+UseSerialGC• Parallel GC (High Throughput) – Use in non- interactive jobs which can tolerate pause of 1- 2 sec – -XX:+UseParallelGC –XX:+UseParallelOldGC• CMS (Low Latency) – Good for webapps and interactive processes – -XX:+UseConcMarkSweepGC

×