Closed atoomic closed 7 years ago
indeed moose is using B::perlstring in multiple places
lib/Moose/Meta/Attribute.pm
936: my $builder = B::perlstring($self->builder);
lib/Moose/Meta/Method/Delegation.pm
93: my $method_name = B::perlstring( $self->name );
94: my $attr_name = B::perlstring( $self->associated_attribute->name );
perlstring is another flavor of cstring, if that's the only one use, we can even provide an alternate for it
void
cstring(sv)
SV * sv
ALIAS:
perlstring = 1
cchar = 2
PPCODE:
PUSHs(ix == 2 ? cchar(aTHX_ sv) : cstring(aTHX_ sv, (bool)ix));
0001-lazy-load-B-at-run-time.txt
idea of lazy loading B at run time in Moose
note that Moose program works when saving B correctly 7f76bf7e62510d434e2ee2681ce25a7a7607d3f8
This still need some extra love but this is a very good start
The compilation of a Moose program like this one create a binary of ~12M and runs about 10x times faster once compiled
moose.t
package foo;use Moose;
has "x" => (isa => "Int", is => "rw", required => 1);
has "y" => (isa => "Int", is => "rw", required => 1);
sub clear { my $self = shift; $self->x(0); $self->y(0); }
__PACKAGE__->meta->make_immutable;
package main;
my $f = foo->new( x => 5, y => 6);
print $f->x . "\n";
Uncompiled
> time for i in $(seq 1 100); do perl moose.t >/dev/null; done
real 0m37.759s
user 0m35.838s
sys 0m1.909s
vs Compiled
> time for i in $(seq 1 100); do moose.bin >/dev/null; done
real 0m4.302s
user 0m3.035s
sys 0m1.273s
This is an acknowledge issue for a while but would be good to be able to understand/fix it in the future.
current status with HEAD=39f6dac5ae2666a40c47c3d2c79d2e4ce848efc9 is a SEGV when bootstrapping B, is Moose using B ??