• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

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

 
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Bartender
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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?
 
Prafull Prashant
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 8
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 9626
16
Mac OS X Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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 can't take it! You are too smart for me! Here is the tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic