An InDepth Examination of Java IO Performance and Possible Tuning Strategies - PowerPoint PPT Presentation

About This Presentation
Title:

An InDepth Examination of Java IO Performance and Possible Tuning Strategies

Description:

Larger buffer? no big gain: Amdahl's law! Does not help in random access ... 220% improvement vs. no buffer. But, still 364%x slower than C ... – PowerPoint PPT presentation

Number of Views:106
Avg rating:3.0/5.0
Slides: 38
Provided by: guo48
Category:

less

Transcript and Presenter's Notes

Title: An InDepth Examination of Java IO Performance and Possible Tuning Strategies


1
An In-Depth Examination of Java I/O Performance
and Possible Tuning Strategies
  • Kai Xu xuk_at_cs.wisc.edu
  • Hongfei Guo guo_at_cs.wisc.edu

2
Outline
  • Why bother? (Problems)
  • Our goals
  • Java I/O overview
  • Tests design
  • Test results and analysis
  • Conclusions

3
Why bother?
  • Growing interest in using Java
  • Much works had been done in Java performance
    evaluation but
  • NOT in Java I/O

4
Our Goals
  • Is it really bad (Compared with C/C)
  • How bad
  • Possible tuning strategies
  • How well they work

5
An Overview of Java I/O Classes
Random AccessFile
6
Test Design
  • Access patterns
  • Sequential write/read
  • Random write/read
  • Data interested
  • Elapse time, CPU breakdown
  • Comparison group C/C

7
Test Design (continued)
  • Tests on basic Java I/O strategies
  • Test 1 The lowest level I/O
  • Test 2 Buffered I/O
  • Test 3 Direct buffering
  • Test 4 Operation size
  • Test 5 Java JNI

8
Test Setup
  • Hardware configuration
  • CPU Pentium III 667 MHz
  • Memory 128 MB
  • Disk 10 GB IDE
  • Software configuration
  • OS Redhat 6.2
  • JVM JDK 1.2.2
  • Profiling Tools
  • PerfAnal profiler, gprof profiler
    2.9.5, time

9
Test 1 The lowest level Java I/O
  • Test parameters
  • buffer size 0 Byte
  • operation size 1 Byte
  • Sequential Write/Read
  • Random Write/Read

10
Sequential Write/Read
11
Breakdown -- File size 100M
12
Random Write/Read
13
Breakdown -- File size 10M
14
Test 1 Analysis
  • Java raw I/O 200x slower
  • Java system calls cost more
  • read 224x
  • write 158x
  • Random Access is similar

15
Test 2 Buffered I/O in Java
  • Test parameters
  • buffer size 1024 Bytes
  • file size 100 MB
  • Sequential Write/Read
  • Buffering Strategies
  • No Buffering
  • (FileInputStream/FileOutputStream)
  • BufferedInputStream/BufferedOutputStream
  • Direct Buffering

16
Buffering Strategies in Java
17
CPU Breakdown
18
Test 2 Analysis
  • Buffering improves I/O
  • reducing system calls
  • Buffered Stream 25
  • Direct Buffering 40
  • special purpose vs. general purpose
  • No buffering for random access

19
Test 3 Direct Buffering
  • Test parameters
  • file size 100 MB
  • operation size 1 Byte
  • Sequential Write/Read
  • Random Write/Read

20
Sequential Write/Read
21
Breakdown Java
22
Breakdown C
23
Random Write/Read
24
Breakdown Java
25
Breakdown C
26
Test 3 Analysis
  • Direct buffering improves I/O 50
  • reducing system calls
  • slower than C/C 300
  • Larger buffer? no big gain Amdahls law!
  • Does not help in random access
  • low hit ratio less than 1

27
Test 4 Operation Size
  • Test parameters
  • buffer size 0 Byte
  • Sequential Write/Read
  • Random Write/Read

28
Sequential Write/Read 100M
29
Random Write/Read 10M
30
Test 4 Analysis
  • Increasing operation size helps 85
  • reducing I/O system calls
  • comparable to C/C
  • Large operation size
  • no big gain.
  • Random Access is similar

31
Test 5 Java JNI
  • Test parameters
  • file size 100 MB
  • buffer size 4 KB
  • Sequential Write/Read

32
Java JNI Buffering
33
Breakdown JNI buffering
34
Test 5 Analysis
  • I/O system calls are cheap (C/C level)
  • But, cost of calling native method is high
  • Small operation size
  • more native calls,
  • comparable to Direct Buffering
  • Large operation size
  • less native calls,
  • comparable to C/C.

35
Conclusions
  • Java raw I/O 200x slower than C
  • Buffering improves I/O
  • Reducing system calls
  • 220 improvement vs. no buffer
  • But, still 364x slower than C
  • Random I/O no help with buffering?
  • locality of access

36
Conclusions (continued)
  • Increasing operation size helps
  • Comparable to C/C
  • JNI
  • system calls are cheap (C/C level)
  • cost of calling native method is high
  • reduce native call times
  • Comparable to C/C

37
Thank You
Write a Comment
User Comments (0)
About PowerShow.com