Skip Menu |

This queue is for tickets about the Moo CPAN distribution.

Report information
The Basics
Id: 105880
Status: resolved
Priority: 0/
Queue: Moo

People
Owner: Nobody in particular
Requestors: dagolden [...] cpan.org
Cc: rabbit [...] rabbit.us
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



CC: rabbit [...] rabbit.us
Subject: Optimize generated constructor by avoiding NEXTSTATE
I was looking at a generated constructor in NYTProf: https://annotate.driftt.com/view?i=b7b9a7gqxeh6xgx%2F2015-07-15_at_10.23_AM.png%2F Discussing it with ribasushi, he told me that he optimized this sort of thing in the DBIC rowparser by using "," instead of ";" to avoid the NEXTSTATE ops. The commit for it indicates a noticeable speed improvement: https://github.com/dbsrgits/dbix-class/commit/05a5ca4b9 He suggested that the generated assignment could be better expressed along these lines: ( exists $args{foo} and $new->{foo} = $args->{foo} ), ( ... ), ( ... ), ... While ugly, it's generated code anyway and probably worth it for the speed improvement.
CC: undisclosed-recipients:;
Subject: Re: [rt.cpan.org #105880] Optimize generated constructor by avoiding NEXTSTATE
Date: Mon, 27 Jul 2015 23:04:39 +0100
To: bug-Moo [...] rt.cpan.org
From: ilmari [...] ilmari.org (Dagfinn Ilmari Mannsåker)
"David Golden via RT" <bug-Moo@rt.cpan.org> writes: Show quoted text
> I was looking at a generated constructor in NYTProf: https://annotate.driftt.com/view?i=b7b9a7gqxeh6xgx%2F2015-07-15_at_10.23_AM.png%2F > > He suggested that the generated assignment could be better expressed > along these lines: > > ( exists $args{foo} and $new->{foo} = $args->{foo} ), ( ... ), ( ... ), ... > > While ugly, it's generated code anyway and probably worth it for the > speed improvement.
The generated code is not that much uglier, actually. See the 'fewer-nextstate-in-new' branch in Moo.git (https://github.com/moose/Moo/commit/fewer-nextstate-in-new) and the attached files which contain all the constructors generated by the Moo test suite, before and after the change.

Message body is not shown because sender requested not to inline it.

Message body is not shown because sender requested not to inline it.

-- - Twitter seems more influential [than blogs] in the 'gets reported in the mainstream press' sense at least. - Matt McLeod - That'd be because the content of a tweet is easier to condense down to a mainstream media article. - Calle Dybedahl
The branch, with several additional optimisations by haarg, has now been merged to master, and this speedup will be in the next release of Moo.
Optimizations have been released in Moo 2.001000