Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Slow startup on raspberry pi

by wollmers (Scribe)
on Jan 16, 2015 at 12:12 UTC ( [id://1113498]=note: print w/replies, xml ) Need Help??


in reply to Slow startup on raspberry pi

Watched the same on Raspberry. A

# mojo version

took 7 seconds. Then I profiled it with Devel::NYTProf with the result, that attribute creation (does string eval) of Mojo::Base was called around 160 times. In combination with the slow I/O to SD-card it results in 10 times slower than my Mac Air (Core i5, SSD), which needs around 0.7 seconds for the same.

Profile your script, and try to tune. Maybe avoid bloated modules (e.g. List::Utils for min()). Or just use better hardware.

Replies are listed 'Best First'.
Re^2: Slow startup on raspberry pi
by LanX (Saint) on Jan 16, 2015 at 12:18 UTC
    But why should a string eval be particularly slower on a pi?

    If IO matters what about copying the modules in one step to a RAM disk?

    Cheers Rolf

    PS: Je suis Charlie!

      String eval is always slow, and it's generally recommended to avoid them when possible on any platform. It's particularly slow on an Rpi, because Rpis are also slow.

      A RAM disk is not a bad idea if you can spare the memory, but I don't think it will be particularly helpful in your case. Since the loadup time at boot is what matters to you, you'll just move that time from the "perl" invocation to the copy command. You *might* see some gains by loading the modules all together with PAR, but that could easily move the problem from I/O to the CPU (due to decompression).

      The first place I would look is making sure you have a good power supply, and the second place is making sure you have a quality SD card.


      "There is no shame in being self-taught, only in not trying to learn in the first place." -- Atrus, Myst: The Book of D'ni.

        Thanks, but I'm not the OP ;)

        and FWIW I'm aware that string eval is slow, but still it shouldn't have a disproportional effect on PI, otherwise I'd like to know why .

        Cheers Rolf

        PS: Je suis Charlie!

      Sorry, expressed myself misleading. One problem is the slow I/O, where the Raspberry spent 5s of 8s in Mojo::Loader, compared with 194ms of 800ms on a MacAir.

      The other problem is the hughe (bloated?) code which affects the runtime on both systems, but a human does not recognize the slowness on the fast system. On fast systems this large amount of CPU-cycles needed for class-factories or other INIT things does not matter, even if a restart of a webapp with 600 modules needs a few seconds.

      Simple Perl like my $x = shift; is typically 17x slower on the Raspy, some other things have lower factors.

        OK thanks I was just wondering, if I missed a detail. :)

        And yes many are not aware that each string eval is restarting the compiler.

        Mojo has the reputation of being lightweight, but 160 small evals instead of one big one will make a difference.

        Of course Web frameworks are not supposed to be restarted very often...

        Cheers Rolf

        PS: Je suis Charlie!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1113498]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (6)
As of 2024-04-19 09:19 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found