develooper Front page | perl.perl5.porters | Postings from March 2011

Re: [perl #82110] Still "keys" performance regression between 5.10.1and 5.12.3-RC1

Thread Previous | Thread Next
From:
demerphq
Date:
March 12, 2011 14:35
Subject:
Re: [perl #82110] Still "keys" performance regression between 5.10.1and 5.12.3-RC1
Message ID:
AANLkTikp=3u3DBCHvzJdaDd0dW01cq=XyVkRrZcdt9rn@mail.gmail.com
are you sure you pushed it? i dont see a mail, and when i pulled i
didnt see any changes...

On 12 March 2011 23:12, Dave Mitchell <davem@iabyn.com> wrote:
> On Sat, Mar 12, 2011 at 10:17:51PM +0100, demerphq wrote:
>> So then this doesn't explain:
>>
>> my @array= keys %$hash;
>>
>> being slower? Isn't that what this thread/bug is about?
>
> The important point is the hash deref on the RHS.
>
> However, this is all happily now irrelevant, with this commit I've just
> pushed, which speeds this case up again:
>
> commit f403e0db17c184bb595ab0dd953ac809957ea768
> Author:     David Mitchell <davem@iabyn.com>
> AuthorDate: Sat Mar 12 22:01:26 2011 +0000
> Commit:     David Mitchell <davem@iabyn.com>
> CommitDate: Sat Mar 12 22:09:52 2011 +0000
>
>    [perl #82111] de-pessimise some my @array = ...
>
>    Due to obscure closure and goto tricks, it's sometimes possible for the
>    array or hash in the LHS of 'my @a = ...' and 'my %h = ...' to be
>    non-empty. At compile-time, these conditions are detected and the assign
>    op is compiled with the OPpASSIGN_COMMON, making the assignment slower.
>
>    This commit speeds it up again by adding a run-time check to pp_aassign
>    to only do the OPpASSIGN_COMMON code-branch if the LHS isn't an empty
>    array or hash.
>
>    See also #70171.
>
>
> Affected files ...
>
>    M   pp_hot.c
>
> Differences ...
>
> diff --git a/pp_hot.c b/pp_hot.c
> index 852ff80..f8a61cb 100644
> --- a/pp_hot.c
> +++ b/pp_hot.c
> @@ -989,8 +989,19 @@ PP(pp_aassign)
>     /* If there's a common identifier on both sides we have to take
>      * special care that assigning the identifier on the left doesn't
>      * clobber a value on the right that's used later in the list.
> +     * Don't bother if LHS is just an empty hash or array.
>      */
> -    if (PL_op->op_private & (OPpASSIGN_COMMON)) {
> +
> +    if (    (PL_op->op_private & OPpASSIGN_COMMON)
> +       &&  (
> +              firstlelem != lastlelem
> +           || ! ((sv = *firstlelem))
> +           || SvMAGICAL(sv)
> +           || ! (SvTYPE(sv) == SVt_PVAV || SvTYPE(sv) == SVt_PVHV)
> +           || (SvTYPE(sv) == SVt_PVAV && AvFILL((AV*)sv) != -1)
> +           || (SvTYPE(sv) == SVt_PVHV && HvKEYS((HV*)sv) != 0)
> +           )
> +    ) {
>        EXTEND_MORTAL(lastrelem - firstrelem + 1);
>        for (relem = firstrelem; relem <= lastrelem; relem++) {
>            if ((sv = *relem)) {
>
>
> --
> O Unicef Clearasil!
> Gibberish and Drivel!
>    -- "Bored of the Rings"
>



-- 
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