TODO hardlink performance optimizations

jw schultz jw at pegasys.ws
Tue Jan 6 03:09:23 GMT 2004


On Mon, Jan 05, 2004 at 01:44:37AM -0600, John Van Essen wrote:
> On Sun, 4 Jan 2004, jw schultz <jw at pegasys.ws> wrote:
[snip]
> Your changes are almost identical to mine, so I will address only the
> main differences...
> 
> > ===================================================================
> > RCS file: /data/cvs/rsync/hlink.c,v
> > retrieving revision 1.23
> > diff -p -u -r1.23 hlink.c
> > --- hlink.c        2 Jan 2004 07:34:49 -0000        1.23
> > +++ hlink.c        4 Jan 2004 13:21:14 -0000
> > @@ -24,45 +24,43 @@ extern int dry_run;
> >  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 **f1, struct file_struct **f2)
> >  {
> > -        if (!S_ISREG(f1->mode) && !S_ISREG(f2->mode))
> > +        if (!S_ISREG((*f1)->mode) && !S_ISREG((*f2)->mode))
> >                  return 0;
> > -        if (!S_ISREG(f1->mode))
> > +        if (!S_ISREG((*f1)->mode))
> >                  return -1;
> > -        if (!S_ISREG(f2->mode))
> > +        if (!S_ISREG((*f2)->mode))
> >                  return 1;
> > 
> > -        if (f1->dev != f2->dev)
> > -                return (int) (f1->dev > f2->dev ? 1 : -1);
> > +        if ((*f1)->dev != (*f2)->dev)
> > +                return (int) ((*f1)->dev > (*f2)->dev ? 1 : -1);
> > 
> > -        if (f1->inode != f2->inode)
> > -                return (int) (f1->inode > f2->inode ? 1 : -1);
> > +        if ((*f1)->inode != (*f2)->inode)
> > +                return (int) ((*f1)->inode > (*f2)->inode ? 1 : -1);
> > 
> > -        return file_compare(&f1, &f2);
> > +
> > +        return file_compare(f1, f2);
> >  }
> 
> 
> 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))

My changes were patterned after file_compare().  The
compiler should produce approximately the same code but
your's is a little more readable.  If we go with yours i'd
suggest we update file_compare() to match.  Consistancy of
code is more important that patch size.

-- 
________________________________________________________________
	J.W. Schultz            Pegasystems Technologies
	email address:		jw at pegasys.ws

		Remember Cernan and Schmitt


More information about the rsync mailing list