2015.07 – I like trains! Fast trains, that is …

This week I’m taking back over from lizmat who thankfully stepped in when other responsibilities kept me away from Perl 6 for a while. I kind of like her format a bit better than my big list of bullet points; I’ll try to do it more like her. Feedback is, of course, always welcome.

Performance improvements

After TimToady posted an implementation of the Textonyms task on RosettaCode that was too slow for comfort, lizmat had a look at the .trans method (which also powers the tr/// operator) and quickly made the common case of having only a Pair of two strings at least 20x faster. Another case of trans – only removing characters instead of replacing characters with others – got between 10x and 200x faster (depending on whether you remove all characters (200x faster) or no characters (10x)). These changes made TimToady’s code run 36x faster, the run time went from 6 minutes down to 10 seconds. Yay!

Availability of “long” type

FROGGS made a type “long” available – especially useful for use with NativeCall – to use whatever the current machine thinks a “long” is. This work also includes the ability to specify sizes for other things. In a related change, Buf objects will now report the correct size in “.bytes” when the size of an individual element is not one byte.

NativeCall’s in Rakudo now

NativeCall has been moved into the same repository that holds Rakudo. The reason for that is that their versions usually have to track each other very closely and having both in the same repository makes things a lot less strenuous.

Stricter laxness

Starting a Perl 6 script with a literal or a bare “v6;” is no longer considered obvious enough for parsing a script in lax mode. Especially since code run on the commandline with perl6 -e are lax by default.

An Interview and also a Blog Post

Paul Krill of Infoworld interviewed Larry Wall last wednesday (comments on reddit). On sunday our very own masak wrote a blogpost on mazes.

Syntax highlighting on doc.perl6.org

Thanks to paul t cochrane ([ptc] on the IRC) we now have syntax highlighted code blocks on doc.perl6.org and avuserow has a branch that uses Inline::Python instead of shelling out for a great performance improvement.

Native references

jnthn has been working on a branch “native-ref” that’s just recently been merged in MoarVM, but currently isn’t being taken advantage of in nqp and rakudo. It will – once merged – allow native values to be lvalues properly for things like having ++ on native values and having rw-accessors on native attributes in classes and working with values in Buf objects and friends. As far as I can tell, the code making use of the changes in the branch will be merged after the 2015.02 release has been tagged.

That’s it from me for this week. I hope I didn’t forget too much; I kind of have to get back into the swing of things 🙂 As always, feel free to point out things that are missing or wrong. See you next week!


9 thoughts on “2015.07 – I like trains! Fast trains, that is …

  1. This makes me sad:
    perl -wnl -E ‘say $1 if /\b(\w{5})\b/’ logs.txt (19Mb) / 1 sec
    ruby -wnl -e ‘puts $1 if /\b(\w{5})\b/’ logs.txt (19Mb) / 1.8 secs
    perl6 -n -e ‘say $0 if m/(<<\w**5>>)/’ logs.txt (19Mb) / 88 secs

    I find it hard to believe that Perl 6 will come anywhere near the speed of Perl 5 by September for what Perl is renowned for: blazing fast text and regex parsing.

    • Hello Gerald,

      could you also try perl6 -n -e ‘1 + 1’ logs.txt to see how that runs? Because right now – and this is what the GLR is going to drastically fix – our code for iterating over stuff is woefully inefficient. My suspicion is that the big majority of the time spent in that piece of code is iterating over the lines of the file, rather than evaluating the regex.

      I’m looking forward to your report 🙂

      • nqp::say($0.Str) speeds it up to 44 seconds. There’s nothing special about the log file, which is why Perl 5.20 parsed it in 1 second, so just grab any old Apache log file and cat >> until it’s 19Mb. The test machine is a 3.24Ghz quad core i7 Mac circa 2010.

    • I forgot to mention one thing in the other reply: “say” currently has quite some overhead to it – I believe the mechanism by which you can override $*OUT dynamically is mostly to blame for this, but people smarter than me have probably already figured out a way to actually improve this. So maybe if there’s many, many matches in your log, that could contribute to a slowdown as well …

      • It’s a poor state of affairs if I can get away with using say in Perl 5 but not in Perl 6 where it originated. To a non-technical observer like myself it gives the impression that Perl 6 is just over-engineered and will struggle to match the performance of its predecessor. I hope I’m wrong.

      • Hey Gerald, can you try “nqp::say($0.Str)” instead of “say $0”? that should give us an idea of how big the overhead induced by $*OUT and stuff is. Thanks!

        Alternatively, if that’s all right with you, I’d like to have the log file so I can experiment with it locally. Otherwise, try perl6 –profile -e … to get a neat little html “app” that’ll let you look at what takes how much time here.

    • The mention of September is curious. The target for September is to produce a “6.0.0 text suite beta” — a first attempt at freezing the syntax and semantics until a passing release has shipped. Thereafter core devs will be free to focus on fixing bugs and increasing speed. It may well be wishful thinking but I’d expect some of the biggest speedups this year to come in those last few months.

Got something to note?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s