TODO hardlink performance optimizations

Wayne Davison wayned at samba.org
Wed Jan 7 06:33:06 GMT 2004


On Mon, Jan 05, 2004 at 01:44:37AM -0600, John Van Essen wrote:
> I did that differently (and more simply, I think).  Changed only one line
> and added two lines:
> 
> @@ -24,8 +24,11 @@
>  extern int verbose;
>  
>  #if SUPPORT_HARD_LINKS
> -static int hlink_compare(struct file_struct *f1, struct file_struct *f2)
> +static int hlink_compare(struct file_struct **f1p, struct file_struct **f2p)
>  {
> +       struct file_struct *f1 = *f1p;
> +       struct file_struct *f2 = *f2p;
> +
>         if (!S_ISREG(f1->mode) && !S_ISREG(f2->mode))
>                 return 0;
>         if (!S_ISREG(f1->mode))

I'd suggest also changing the last line of the function:

-	return file_compare(&f1, &f2);
+	return file_compare(f1p, f2p);

This is because the old way asks the compiler to take the address of f1
and f2, thus forcing them to become real stack variables.  Changing the
code to use the passed-in f1p and f2p allows the compiler to leave both
f1 and f2 as registers (if possible).

..wayne..


More information about the rsync mailing list