This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Using memcpy instead of `*dst++ = *src++'
- To: Dirk Herrmann <dirk at ida dot ing dot tu-bs dot de>
- Subject: Re: Using memcpy instead of `*dst++ = *src++'
- From: "Dale P. Smith" <dpsm at en dot com>
- Date: Tue, 6 Jun 2000 07:59:10 -0400
- CC: "guile at sourceware dot cygnus dot com" <guile at sourceware dot cygnus dot com>
- Organization: Altus Technologies Corporation.
- References: <Pine.LNX.4.21.0006061132020.4334-100000@marvin.ida.ing.tu-bs.de>
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