On Wed, Sep 25, 2024 at 07:16:26AM +0000, Manoj Kumar via IBM TechXchange Community wrote:
> We are trying to copy a directory which is having lot of files
> (1760000). It is taking lot of time to copy from one directory to
> another on the same server. (Approx 1hr 15 min)
>
> Even commands like ls, du also takes longer time to complete.
>
> Is this normal behavior? or we can do something at OS to speed up
> the copy. Any suggestion would be highly appreciated.
Manoj,
Directories and filesystems with high file counts are often slow in
listing and copy operations. It's due to interacting with the file
metadata (inode table/trees), which is synchronously written.
It's a common problem I see on AIX and other operating systems once
you hit over a million files. I've had a customer with 16 Million
files in one directory, and ls would fault due to memory. I've had
migrations that took days because of the file count.
Large numbers of (typically small) files are an exotic storage
configuration, and many filesystems struggle with them. AIX is no
exception. You will want to consider reorganizing how these files are
stored.
If you find yourself interacting with lots of files, here's a few
tips.
Don't use "ls" and never use shell globbing (ie: *). Use "find"
instead.
If you can, mount the filesystem with log=NULL and see if that helps
speed things up for adding and removing files. This is only temporary
(ie: for migration). Do not leave your filesystems mounted with
log=NULL.
You might have some success "dd"ing the raw logical volume to faster
storage and repeating the operation. Maybe consider a ramdisk (with
backups). It's the filesystem that's slow, not the storage. You can
operate against the LV at full speed.
Try breaking up many files in a single directory into subdirectories
if possible. That will really improve your listing commands. For
example, if you had 26000 files starting with A-Z in a single
directory, create subdirs A-Z and put 1000 files in each. It'll speed
up.
Consider using storage features for backup like flashcopy, so you can
mount a snapshot of the data to another server. Backups are often a
real problem with these scenarios, as most backups will inventory a
list of files (slow full traversal), followed by a second full
traversal and reading the contents. The inventory can even negatively
impact running applications!
Try to package files into tar balls or other container formats,
instead of leaving individual files on disk.
TL;DR: Too many files in one directory hurts, split it up.
Good luck.
------------------------------------------------------------------
Russell Adams
Russell.Adams@AdamsSystems.nlPrincipal Consultant Adams Systems Consultancy
https://adamssystems.nl/
Original Message:
Sent: 9/25/2024 3:16:00 AM
From: Manoj Kumar
Subject: Copy a huge size of directory which have lot of files inside it, taking longer time
Hi Team,
We are trying to copy a directory which is having lot of files (1760000). It is taking lot of time to copy from one directory to another on the same server. (Approx 1hr 15 min)
Even commands like ls, du also takes longer time to complete.
Is this normal behavior? or we can do something at OS to speed up the copy. Any suggestion would be highly appreciated.
------------------------------
Manoj Kumar
------------------------------