img
.
public void add(Request request) {
list = list.cons(request);
length++;
}
public Request remove() {
Request request = (Request) list.first;
list = list.next;
length--;
return request;
}
public boolean empty() {
return length == 0;
}
public boolean full() {
return length == max;
}
}
Disk Performance with Java
Our final program (Code Example 17-7) is a simple test of disk performance with multiple threads.
Because disk controllers can overlap incoming requests from the CPU, having lots of outstanding
requests is a good thing and yields a performance improvement upward of twofold. This program
demonstrates that fact and the value of making native call to thr_setconcurrency() on
Solaris platforms. A nearly identical program in C yields slightly (about 25%) better results due to
the expense of Java making calls into the native read() system call.
Example 17-7 Measuring Disk Access Throughput
// TimeDisk/Test.java
/*
This program runs a set of read() calls against one large file.
It runs with one or more threads so you can see the performance
effect of MT.  Each read() gets one byte from a random location.
You can run it for a number of iterations and get mean and SD.
Make sure that there are links in /tmp pointing to wherever you
can find room.
lrwxrwxrwx
1 bil other ... time_disk0.tmp ->
/disk2/6/temp_disk_test
ln -s /disk2/6/temp_disk_test /tmp/time_disk0.tmp
The file must be much larger than physical memory.  10x would be
great,
but 2x will do.  Expect "performance" to improve as the mbufs get
loaded.  For a file 2x Physical, initial 100/s will improve to
200/s
(as 50% of the file will become cached).  To populate the cache,
you
can run this program for awhile.
Search WWH :
Custom Search
Previous Page
Multithreaded Programming with JAVA - Topic Index
Next Page
Multithreaded Programming with JAVA - Bookmarks
Home