Does Raku always parse?

368 Views Asked by At

raku -version This is Rakudo version 2020.01 built on MoarVM version 2020.01.1 implementing Perl 6.d.

Currently it looks like I can't start any Raku Perl6 program with a runtime lower than about 130 ms (mostly startup time).
-Is Raku always reparsing the complete source on program start ?
-Is Raku caching any Bytecode ?
-So running even a onliner always takes >= 130 ms ?

time raku --stagestats hello_world.pl
Stage start      :   0.000
Stage parse      :   0.133
Stage syntaxcheck:   0.000
Stage ast        :   0.000
Stage optimize   :   0.002
Stage mast       :   0.006
Stage mbc        :   0.001
Stage moar       :   0.000
hello world
hello world
TEST
hello world

real    0m0,183s
user    0m0,231s
sys 0m0,016s
1

There are 1 best solutions below

3
On

Is Raku always reparsing the complete source on program start ?

If you mean your script? Yes. Only modules are currently pre-compiled.

If you mean the entire Raku setting? No, then you would look at 100x more than that.

Is Raku caching any Bytecode ?

Installed modules and modules accessed through -Ilib are cached in .precomp directories.

So running even a onliner always takes >= 130 ms ?

On my machine it's around 120 msecs. But yeah, in that ballpark. At this point in time. Part of this is caused by a number of initializations that are done on startup: although a lot of care has been taken to make sure no unnecessary initializations are done at startup, this has not had the scrutiny of many years like Perl.

If you are comparing this to e.g. Perl, you should realize that Raku gives you Moose built in. If you run perl -MMoose -e '' on my machine, the startup time is just a few milliseconds below that of Raku.