This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Using memcpy instead of `*dst++ = *src++'


Dirk Herrmann wrote:
> 
> On Mon, 5 Jun 2000, Dale P. Smith wrote:
> > Does it make any sense to change scm_makfromstr from:
> >   while (len--)
> >     *dst++ = *src++;
> > to something like:
> >   memcpy (SCM_CHARS (s), src, len);

> I have done a similar change with the continuations:  The stack copying
> functions now use memcpy.  This brought an impressive speedup on sparc
> solaris, but was not noticeable on my pentium linux machine.
> 
> However, for the continuations there's a lot of stuff to be copied, while
> the typical strings may be quite short.  It could be interesting to check
> whether the length is larger than a certain threshold and then either call
> memcpy or not.  The advantage is, that for short strings the penalty is
> just a comparison of the length with the threshold plus a branch, but not
> the procedure call overhead.  It may be, though, that memcpy is a macro
> which does exactly this:  Check the length and either perform inline
> copying or call a function.  I have not checked this, though.

On my system, Pentium II with glibc 1.2, a memcpy is a macro that has *lots* of inline optimizations (loop unrolling etc) for *constant* lengths.  If the length is unknown at compile time, memcpy is
called instead. :(  

I'm going to try some tests and see. I'm sure it's not going to speed up guile that much, I just want to know for future reference.

-Dale
-- 
Dale P. Smith
Altus Technologies Corp.
dsmith@altustech.com
400-746-9000 x309

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]