I've a directory on a NAS mount (from NetApp), that contains ~6300 image files, total size of this directory is ~ 300 MB. I get two different performances of time ls:

First time (or after waiting 5-7 minutes):

time ls

real    0m4.505s
user    0m0.061s
sys     0m0.258s

Subsequent times:

time ls

real    0m0.340s
user    0m0.038s
sys     0m0.075s

I'm fairly new to storage and disks, but my questions are:

  • what causes ls to be slow in some instances and 10+ times fast in others?
  • how would I go about troubleshooting this issue?


Here is what I got back from the sysadmin on how NAS is mounted:

nashost:/vol/cmsprd/files    /app/files      nfs     noquota,proto=tcp       0       0

and here is what I see running for "nfs" on the host:

ps -ef | grep nfs
root      3234     2  0 Mar21 ?        00:00:02 [nfsiod]

I'm still looking for the connection speed.


  • Network congestion a possibility?
    – Tim
    Jul 25 '12 at 19:08
  • @Tim: Thanks, what tools can I use to ascertain that?
    – KM.
    Jul 25 '12 at 19:10
  • you can use WireShark to watch network traffic, or you can use iperf to check the bandwidth between two devices. With WireShark, look for things like retransmission, timeouts while capturing.
    – Tim
    Jul 25 '12 at 19:52
  • What nfs options do you use for mounting the share? Do you have the option 'noac' activated? How many rpcd threads are running (ps -ef | grep '\[nfsd\]' | wc -l)?
    – Huygens
    Jul 26 '12 at 10:50
  • @Huygens, thanks for dropping in. I've updated the question with an answer.
    – KM.
    Jul 26 '12 at 19:10

This could be due to HD spindown.

Some systems have a feature that after some time of Hard Disk's inactivity (no write nor reads) will phisically spin down the rotation of such drive to full stop. This is meant to extend Hard Disk life (less meccanical wear = less likelly to breakdown).

You are observing a 4/5 second slow down after waiting 5-7 minutes, so 5 minues that could be the spin down time of your device. The 5 second wait is the time it get to full spin up the drive to be ready to be accessed.

You can even hear the absence of noise (humm) from the case of the NAS when the HHD is spinned down.

Try to seach in this NAS administrative page (or whatewer) if there is a paramiter like "HD spindown time" to change.


IIRC, ls's output is cached.

How fast is your connection to the NAS? That could be a part of it. The filesystem and HDD speed may have something to do with it, too. Could you provide a little more information?

  • 1
    No, the output from ls will not get cached Jul 25 '12 at 22:34
  • @UlrichDangel Indeed the output from ls isn't cached, but the input to ls (the directory contents as read from the disk by the kernel) is cached. Jul 25 '12 at 23:33
  • @Gilles yes but this also depends on the available memory on the system. Anyway with a NAS this is (depends on the method used to connect to the system) done remotely. Jul 25 '12 at 23:42
  • 1
    Basically, when ls read the inodes and the directory file, the kernel load some of the block of the device (here nfs) and cache them, so subsequent ls call (unless the cache is made expired) are server directly from the local memory.
    – Huygens
    Jul 27 '12 at 19:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.