[Top][All Lists]

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

mkdir efficiency

From: David Feuer
Subject: mkdir efficiency
Date: Wed, 15 Jun 2005 17:04:20 -0400
User-agent: Mutt/1.5.9i

mkdir does not optimize for the case of multiple directories created
with shared prefixes.  If, say, I write
mkdir /a/b/c/d/e /a/b/c/d/f /a/b/c/d/g ....
mkdir will likely waste more OS resources than necessary.  Things are
much worse when using -p:
mkdir -p /a/b/c/d/e /a/b/c/d/f /a/b/c/d/g ....
will go to a tremendous amount of totally unnecessary trouble.


1.  Always try to create the directory directly, even when -p is used.
Only use make_path when this fails.

2.  If anyone thinks this matters, turn the arguments into a collection
of prefix trees, or whatever you call them.  Then save intermediate
working directories for all nodes with more than one child avoid
starting over from the beginning every time.  This may be a bit tricky,
but could be a win when people do stupid things in shell scripts.

David Feuer

reply via email to

[Prev in Thread] Current Thread [Next in Thread]