[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

ls needs several minutes calling getdents (ext4 squeeze)



Hi List,

I have a performance problem with my ext4 filesystem. In one directory, the first time I run ls after a reboot, it takes more than two minutes.
Subsequent runs of the same command are very quick.

(The directory contains 54 files and one subdirectory, and it was first created by git via a git-clone run.)

Details below.

Has anyone else seen similar behaviour?

/ johan


-------------------------


(squeeze on a laptop, / and /home on separate partitions, both are ext4 filesystems created by the debian installer)

After a reboot, and after letting gnome start normally, I cd to the directory and run "strace -T ls". Almost every call reported takes less than a millisecond, except one call to getdents on the current directory.

From the output of "strace -T ls", in a directory on the /home partition:


[...]
open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 <0.000023>
fstat(3, {st_mode=S_IFDIR|0755, st_size=48648192, ...}) = 0 <0.000020>
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC) <0.000015>
getdents(3, /* 57 entries */, 4096)     = 2096 <152.245799>
getdents(3, /* 0 entries */, 4096)      = 0 <0.000023>
close(3)                                = 0 <0.000030>
[..]


For a subsequent call to ls, the corresponding output is:

open(".", O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC) = 3 <0.000024>
fstat(3, {st_mode=S_IFDIR|0755, st_size=48648192, ...}) = 0 <0.000019>
fcntl(3, F_GETFD)                       = 0x1 (flags FD_CLOEXEC) <0.000015>
getdents(3, /* 57 entries */, 4096)     = 2096 <0.059663>
getdents(3, /* 0 entries */, 4096)      = 0 <0.000008>
close(3)                                = 0 <0.000009>


which is a factor of 3000 faster for the first call to getdents.



Reply to: