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

Re: reading an empty directory after reboot is very slow



On Mon, Apr 13, 2015, at 19:28, Bob Proulx wrote:
> 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

Do a forced e2fsck run on the filesystem, and it should add the indexes to all directories that lack it.  It can also change the hash algorithm.

BTW, the e2fsck manpage states that it WILL compress directories if it has any reason to touch the directory.

If you want e2fsck to rehash or compress all directories, you have to run it as e2fsck -D so that it will optimize/rehash every directory, not just those that were lacking indexes or that had to be repaired.

> 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.

If you have the resources required (RAM), always have ephemeral "tmp" directories in tmpfs.  All contents will be discarded on reboot/poweroff or if you umount the tmpfs, but it should be the fastest possible filesystem in Linux as long as you don't start swapping (xfs and ext4 are much better optimized to the "hit the spinning rust" case than tmpfs+swapper IME).

-- 
  "One disk to rule them all, One disk to find them. One disk to bring
  them all and in the darkness grind them. In the Land of Redmond
  where the shadows lie." -- The Silicon Valley Tarot
  Henrique de Moraes Holschuh <hmh@debian.org>


Reply to: