develooper Front page | perl.perl5.porters | Postings from November 2016

Re: A possible new approach to COW - COW_META.

Thread Previous | Thread Next
From:
demerphq
Date:
November 7, 2016 09:38
Subject:
Re: A possible new approach to COW - COW_META.
Message ID:
CANgJU+WZjoTU6Omuo1kRpL+L_R8WKVezgQS8HrxhH5ffq2bz2g@mail.gmail.com
On 7 November 2016 at 10:12, Dave Mitchell <davem@iabyn.com> wrote:
> On Sun, Nov 06, 2016 at 12:50:37PM -0800, Father Chrysostomos wrote:
>> On Nov 6, 2016, at 7:13 AM, demerphq <demerphq@gmail.com> wrote:
>> > Today I pushed a branch, yves/cow_meta.
>> >
>> > This branch is my take on reworking COW so it does not store the
>> > refcount in the string.
>>
>> Have you benchmarked it at all?  I tried something similar at first (but
>> not quite as clean), and found that it made things slower than no COW at
>> all.
>
>
> Using the following benchmark file:

Thanks Dave!

>     [
>         'sassign1' => {
>             desc   => 'assign string length 1',
>             setup   => 'my $s = "x" x 1; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>
>         'sassign10' => {
>             desc   => 'assign string length 10',
>             setup   => 'my $s = "x" x 10; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>
>         'sassign100' => {
>             desc   => 'assign string length 100',
>             setup   => 'my $s = "x" x 100; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>
>         'sassign1k' => {
>             desc   => 'assign string length 1000',
>             setup   => 'my $s = "x" x 1_000; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>         'sassign10k' => {
>             desc   => 'assign string length 10_000',
>             setup   => 'my $s = "x" x 10_000; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>
>         'sassign100k' => {
>             desc   => 'assign string length 100_000',
>             setup   => 'my $s = "x" x 100_000; my $t;',
>             code    => '$t = $s; $t = ""',
>         },
>
>     ];
>
> I get the following. bleadNC is blead built with -DPERL_NO_COW. These are
> raw numbers - lower is better.
>
>
> Key:
>     Ir   Instruction read
>     Dr   Data read
>     Dw   Data write
>     COND conditional branches
>     IND  indirect branches
>     _m   branch predict miss
>     _m1  level 1 cache miss
>     _mm  last cache (e.g. L3) miss
>     -    indeterminate percentage (e.g. 1/0)
>
> The numbers represent raw counts per loop iteration.
>
> sassign1
> assign string length 1

I /think/ these numbers reflect the fact that the current iteration
will COW a 1 byte string, and the old one wont cow it at all.

>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir    478.0    499.0    656.0
>     Dr    155.0    155.0    222.0
>     Dw     74.0     74.0    111.0
>   COND     82.0     90.0    112.0
>    IND     13.0     13.0      9.0
>
> COND_m      0.0      2.1      0.0
>  IND_m      8.0      8.0      6.0
>
>  Ir_m1      0.0      0.0      0.0
>  Dr_m1      0.0      0.0      0.0
>  Dw_m1      0.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> sassign10
> assign string length 10
>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir    480.0    626.0    656.0
>     Dr    156.0    210.0    222.0
>     Dw     75.0    107.0    111.0
>   COND     82.0    104.0    112.0
>    IND     13.0      9.0      9.0
>
> COND_m      0.0      0.1      0.0
>  IND_m      8.0      6.0      6.0
>
>  Ir_m1      0.0      0.1      0.0
>  Dr_m1      0.0      0.0      0.0
>  Dw_m1      0.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> sassign100
> assign string length 100
>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir    492.0    626.0    656.0
>     Dr    161.0    210.0    222.0
>     Dw     80.0    107.0    111.0
>   COND     80.0    104.0    112.0
>    IND     13.0      9.0      9.0
>
> COND_m      0.0      0.0      0.0
>  IND_m      8.0      6.0      6.0
>
>  Ir_m1      0.0      0.1      0.0
>  Dr_m1      0.0      0.0      0.0
>  Dw_m1      0.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> sassign1k
> assign string length 1000
>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir    649.0    626.0    656.0
>     Dr    218.0    210.0    222.0
>     Dw    136.0    107.0    111.0
>   COND     91.0    104.0    112.0
>    IND     13.0      9.0      9.0
>
> COND_m      1.0      0.2      0.0
>  IND_m      6.0      6.0      6.0
>
>  Ir_m1      0.0      0.1      0.0
>  Dr_m1      0.0      0.0      0.0
>  Dw_m1      0.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> sassign10k
> assign string length 10_000
>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir   2059.0    628.0    656.0
>     Dr    781.0    208.0    222.0
>     Dw    699.0    107.0    111.0
>   COND    162.0    105.0    112.0
>    IND     13.0      9.0      9.0
>
> COND_m      2.0      1.2      0.0
>  IND_m      6.0      6.0      6.0
>
>  Ir_m1      0.0      0.1      0.0
>  Dr_m1      0.0      0.0      0.0
>  Dw_m1      0.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> sassign100k
> assign string length 100_000
>
>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir  19254.0    628.0    656.0
>     Dr   6407.0    208.0    222.0
>     Dw   6324.0    107.0    111.0
>   COND    867.0    105.0    112.0
>    IND     13.0      9.0      9.0
>
> COND_m      2.0      1.2      0.0
>  IND_m      6.0      6.0      6.0
>
>  Ir_m1      0.0      0.0     -0.1
>  Dr_m1   1605.0      0.0      0.0
>  Dw_m1   1569.0      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
> AVERAGE

Perhaps I am being overoptimistic but these numbers dont look /too/
different to me.

And I pretty confident that further iterations on this patch series
will change some of the numbers favourably.

>         bleadNC    blead     yves
>        -------- -------- --------
>     Ir   3902.0    605.5    656.0
>     Dr   1313.0    200.2    222.0
>     Dw   1231.3    101.5    111.0
>   COND    227.3    102.0    112.0
>    IND     13.0      9.7      9.0
>
> COND_m      0.8      0.8      0.0
>  IND_m      7.0      6.3      6.0
>
>  Ir_m1      0.0      0.1     -0.0
>  Dr_m1    267.5      0.0      0.0
>  Dw_m1    261.5      0.0      0.0
>
>  Ir_mm      0.0      0.0      0.0
>  Dr_mm      0.0      0.0      0.0
>  Dw_mm      0.0      0.0      0.0
>
>
> --
> "You may not work around any technical limitations in the software"
>     -- Windows Vista license



-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About