File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes I/O and Streams and the fly likes Using Random access file to write to a file with long absolute path take long time in unix Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » I/O and Streams
Bookmark "Using Random access file to write to a file with long absolute path take long time in unix" Watch "Using Random access file to write to a file with long absolute path take long time in unix" New topic
Author

Using Random access file to write to a file with long absolute path take long time in unix

Prafull Prashant
Greenhorn

Joined: Jan 15, 2010
Posts: 8
Hi All,

I am using RandomAccessFile to write data to a file. I am running performance test on my code on solaris machine.

If provide a shorter path for the file lets say "/tmp/", the records are written in expected time in sync with the requests I am sending through my client program.
But when I provide a longer path like /tmp/javaranch/saloon/home/greenhorns/random/access/file", it takes lot of time to write record in time. Even if the client has stopped producing data, the server keeps on writing records (client puts records in a queue and leaves) for next few minutes.

This behaviour is mainly visible in Unix machine. On windows machine I am not able to see any significant delay in writing.

Can anyone throw light on this?


Prafull

SCJP
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

Interesting. Have you tried it with different Java classes (i.e. FileWriter or FileOutputStream) to see if it is a Java problem or a Unix problem?
What flavor of Unix are you using? What filesystem is the drive? Is the drive local or on the network? How much free space does the drive have?


"blabbing like a narcissistic fool with a superiority complex" ~ N.A.
[How To Ask Questions On JavaRanch]
Prafull Prashant
Greenhorn

Joined: Jan 15, 2010
Posts: 8
Simple FileOutputStream doesn't create this problem. Following is the specification of the system i am using:

SunOS incdcs73 5.10 Generic_142900-03 sun4v sparc SUNW,Sun-Fire-T200

The file system is UFS and the free space is ample which is in GBs.
Prafull Prashant
Greenhorn

Joined: Jan 15, 2010
Posts: 8
One information which I wanted to share is I am opening the file in "rwd" mode. Can this create a problem? because when I opened the file in "rw" mode performance improved a lot.
Joe Ess
Bartender

Joined: Oct 29, 2001
Posts: 8707
    
    6

Prafull Prashant wrote:One information which I wanted to share is I am opening the file in "rwd" mode. Can this create a problem? because when I opened the file in "rw" mode performance improved a lot.


Big time:

"rwd" = Open for reading and writing, as with "rw", and also require that every update to the file's content be written synchronously to the underlying storage device.

RandomAccessFile javadoc

Since "rwd" mode requires synchronous updates, it is going to be much slower than "rw"
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using Random access file to write to a file with long absolute path take long time in unix
 
Similar Threads
Random access reads and writes
Help Please- on design approach for data collection across n/w
RandomAccessFile
Passed with 348/400
problem in RunTime.exec