Vincent Lefevre wrote: > Loïc Grenié wrote: > > Vincent Lefevre wrote: > > > The problem is that this operation is (always?) very slow: something > > > like 100 seconds (1 minute and 40 seconds). It has been reproducible > > > for several months. The logs show nothing during this operation. > > > > > > Any idea?
Of course immediately after a reboot the file system buffer cache is completely clean. You can avoid the reboot and recreate this situation by this: # echo 3 > /proc/sys/vm/drop_caches See this for the documentation: https://www.kernel.org/doc/Documentation/sysctl/vm.txt That would certainly be less disruptive to recreate the situation than rebooting the entire system. > > Maybe the directory is very large (even though its empty). Try > > > > ls -ld tmp. > > > > and see if the file "tmp" is large. > > Thanks! I didn't know that (I thought that the file system would > automatically "optimize" directories when files are removed, so > I've never looked closely at their size). Indeed: > > ypig:~/eftests> ls -ld tmp > drwxr-xr-x 2 vlefevre vlefevre 29655040 2015-04-13 15:25:55 tmp/ What type of file system is it? Does it have dir_index? Both ext3 and ext4 support it. Others are similar. # tune2fs -l /dev/mapper/v1-var | grep --color Filesystem.features Filesystem features: has_journal ext_attr resize_inode dir_index filetype needs_recovery sparse_super large_file Without dir_index an ext filesystem with large directories is slow due to the linear nature of directories. But with dir_index it should be using a B-tree data structure and should be much faster. This can be turned off for a migration if it is off. tune2fs -O dir_index /dev/sda5 But existing directories are not converted. Only new directories are converted. So if you have an older machine that has been upgraded and upgraded and upgraded then all of the existing directories will still be the previous linear data structure. Only new directories get the tree data structure. One would need to recreate directories in order to migrate from the old to the new. Very few directories really need it though so for the most part that is okay. It is only directories such as /tmp that sporadically might have surged large that really benefit from a manual recreation conversion in order to have B-trees turned on for a migration to dir_index. Bob
signature.asc
Description: Digital signature