Mike Lambert wrote:

> Just for fun, can you run Hanoi on CVS versus CVS+COW?
>
> I just got COW implemented here, and while I get a 17% speedup on
> life, I get a 5% loss on hanoi. Since you only posted life, it's a
> bit hard to see if the drop on hanoi is just my fault, or the fault of
> COW in general.

Hanoi is a difficult case because pretty much the only string
manipulation it does is repeat, which doesn't benefit from COW,
so all you get is the additional overhead in the compaction code
without any compensating gains.

I have started doing the timings; however, I no longer have a correct
COW-only patch, so I need to do a bit of fiddling. I will post the results
as soon as I have them.

Attached is my current 'African Grey' patch as discussed yesterday.
Also, since you mention hanoi, here (in straight code format, I'm too
lazy to do a diff) is an experimental version of string_repeat that
tries to reduce the number of calls to memcpy. I can't find my notes
at the moment as to what benefit it gave - perhaps you might like
to try it sometime. (Note that the string_make call will need to be
changed to the split chartype/encoding version)

--
Peter Gibbs
EmKel Systems

STRING *
string_repeat(struct Parrot_Interp *interpreter, const STRING *s, UINTVAL
num)
{
    STRING *dest;
    UINTVAL i;
    char *ptr;

    dest = string_make(interpreter, NULL, s->bufused * num, s->charset, 0);
    if (num == 0) {
        return dest;
    }

    dest->bufused = s->bufused * num;
    dest->strlen = s->strlen * num;

    mem_sys_memcopy(dest->bufstart, s->bufstart, s->bufused);
    i = 1;
    num--;
    ptr = (char *)dest->bufstart + s->bufused;
    while (num) {
        mem_sys_memcopy(ptr, dest->bufstart, s->bufused * i);
        ptr += (s->bufused * i);
        num -= i;
        i *= 2;
        if (i > num) {
           i = num;
        }
    }

    return dest;
}

Attachment: grey1.patch
Description: Binary data

Reply via email to