Subject: Re: rename() over NFS

From: Jim Meyering <[email-masked]>
Date: Sat, 13 Nov 2010 15:30:48 +0100

Bruno Haible wrote:
> Jim Meyering wrote:
>> if you see ways to improve things without impacting performance
>> or maintainability, I'm all for it.
>
> Maintainability wouldn't be impacted, because the fix would be to use
> lib/rename.c, with
>   #define RENAME_DEST_EXISTS_BUG 1
>   #define RENAME_HARD_LINK_BUG 1
>
> But performance would be impacted, since 2 lstat() calls would happen
> before every rename().

That sounds like it would be excessive.
Currently, moving 100 regular files into a subdir
incurs 100% of its time in 100 rename and 200 stat calls:

% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 79.69    0.000051           1       100           rename
 20.31    0.000013           0       200       100 lstat
  0.00    0.000000           0         8           read

Adding a rename wrapper and doubling the number of lstat calls
per file would represent a significant slow-down.