in reply to Pass by ref vs alias : why does scalar size matter?

On a moderately loaded Solaris machine, alias keeps ahead of ref, but it seems that the string length dominates the speed, as both rates get lower and closer to each other with no signs of one overtaking the other:

Length of string: 1000 Rate ref alias alias 141243/s 58% -- ref 89366/s -- -37% ... Length of string: 10000 Rate ref alias alias 45496/s 19% -- ref 38388/s -- -16% ... Length of string: 20000 Rate ref alias alias 25947/s 12% -- ref 23186/s -- -11%

This is for

This is perl, v5.8.4 built for sun4-solaris-64int (with 27 registered patches, see perl -V for more detail)

On a different machine, also moderately loaded, I see practically the same, also with alias keeping (barely) ahead of ref as the string size increases:

Length of string: 1000 Rate ref alias alias 404858/s 115% -- ref 187970/s -- -54% Length of string: 2000 Rate ref alias alias 367647/s 87% -- ref 196850/s -- -46% ... Length of string: 10000 Rate ref alias alias 220751/s 24% -- ref 177936/s -- -19% ... Length of string: 18000 Rate ref alias alias 168067/s 2% -- ref 165563/s -- -1% Length of string: 19000 Rate alias ref ref 162866/s 1% -- alias 161551/s -- -1% Length of string: 20000 Rate alias ref ref 162602/s 2% -- alias 160000/s -- -2%

Here, the decrease in repetitions is more dramatic for alias as the string length increases, which I interpret as the runtime overhead of alias being really minuscule compared to the overhead of the other operations performed.

This is on a HP-UX machine with Intel architecture:

This is perl, v5.8.8 built for IA64.ARCHREV_0-thread-multi (with 33 registered patches, see perl -V for more detail) Copyright 1987-2006, Larry Wall Binary build 817.1 [268662] provided by ActiveState http://www.ActiveS +tate.com Built Sep 19 2006 13:53:03

Interestingly, trying this with Strawberry 5.10.0, I see your reversal (Intel architecture):

Rate ref alias ref 258065/s -- -46% alias 477783/s 85% -- ... Length of string: 10000 Rate alias ref alias 123533/s -- -25% ref 164528/s 33% -- ... Length of string: 20000 Rate alias ref alias 65509/s -- -42% ref 112867/s 72% --

This is for

This is perl, v5.10.0 built for MSWin32-x86-multi-thread

Trying on the same machine with Strawberry 5.8.8, I get

Length of string: 1000 Rate ref alias alias 511771/s 53% -- ref 335121/s -- -35% Length of string: 2000 Rate ref alias alias 383289/s 28% -- ref 299043/s -- -22% Length of string: 3000 Rate ref alias alias 318471/s 14% -- ref 279486/s -- -12% Length of string: 4000 Rate ref alias ref 256016/s -- -2% alias 262329/s 2% -- Length of string: 5000 Rate alias ref alias 219154/s -- -7% ref 236183/s 8% -- ... Length of string: 10000 Rate alias ref alias 121448/s -- -29% ref 170707/s 41% -- ... Length of string: 20000 Rate alias ref alias 67801/s -- -39% ref 111694/s 65% --

This was with:

This is perl, v5.8.8 built for MSWin32-x86-multi-thread

So, at least judging from the limited set of versions and platforms, things point in the direction of Windows or MSVC to be responsible for the dramatic slowdown although I'm at a loss as to what part might be causing the slowdown.

Replies are listed 'Best First'.
Re^2: Pass by ref vs alias : why does scalar size matter?
by clinton (Priest) on May 02, 2008 at 11:29 UTC
    So, at least judging from the limited set of versions and platforms, things point in the direction of Windows or MSVC to be responsible for the dramatic slowdown although I'm at a loss as to what part might be causing the slowdown.

    Not only Windows, because I'm running mine on Linux:

      This would leave "x86" architecture as the only common thing. My "weird" Perls are running under 32-bit Windows x86 (Intel Celeron 2.8 GHz). You are seeing this under 64-bit Linux (AMD?).

      But the HP-UX machine also is a 64-bit x86 machine (Intel Xenon Server CPUs), and it doesn't exhibit the problematic behaviour.

        Same (clinton's) results here on a MacMini running Ubuntu, so it doesn't seem a processor specific issue:

        This is perl, v5.8.8 built for powerpc-linux-gnu-thread-multi
        It's an Intel core duo, but yes: AMD like