Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

What can affect perl startup time?

by nysus (Parson)
on Mar 23, 2022 at 01:24 UTC ( [id://11142295]=perlquestion: print w/replies, xml ) Need Help??

nysus has asked for the wisdom of the Perl Monks concerning the following question:

I ran an empty perl script with just a single exit command on my newer 2020 intel-based imac running stock 5.34 and ran 100 times with time (repeat 100 {./time.pl})

Got this: 0.39s user 0.28s system 89% cpu 0.743 total

I was surprised to see slightly better results on a 2014 imac running stock 5.30: 0.33s user 0.26s system 81% cpu 0.718 total

So I'm wondering what might be slowing my newer mac down. It's not particularly heavily loaded. And is there anything I can do anything to improve its performance? Thanks.

$PM = "Perl Monk's";
$MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
$nysus = $PM . ' ' . $MC;
Click here if you love Perl Monks

Replies are listed 'Best First'.
Re: What can effect perl startup time?
by GrandFather (Saint) on Mar 23, 2022 at 01:57 UTC

    If I understand you correctly you are suggesting a load/execute time of the order of 5ms. That is comparable with hard drive (spinning rust version) seek times. So what you are measuring is simply the OS's overhead for loading and executing Perl and Perl's overhead for loading, compiling and executing your script. Given your script is essentially a no-op, you are asking us to guess why your OS and hardware are performing differently than some other past combination you had. We are supposed to do that how? And it matters why?

    If you are running a web server and that represents overhead in page fetches there are ways to mitigate the problem. Is that the question you should be asking?

    Optimising for fewest key strokes only makes sense transmitting to Pluto or beyond

      Some of it is out of curiosity and some of it is is I have a shell function wrapping a perl script which does tab completion and I wanted to get a baseline.

      My m1 mac is almost 100% faster: 0.21s user 0.13s system 85% cpu 0.399 total

      Given the non-difference between my 2020 imac and 2014 imac, I'm wondering if I might have something configured in a way that is slowing things down. Both are running SSD drives but the 2020 machine has a very beefy processor. So that leads me to believe there is some kind of bottleneck on the newer mac. Maybe it's the OS version (Big Sur vs. Monterey). But the m1 and the 2020 imac are running the same OS version and there is a huge difference.

      So I'm very curious to know what might explain the similar times between the older mac and the newer one.

      $PM = "Perl Monk's";
      $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
      $nysus = $PM . ' ' . $MC;
      Click here if you love Perl Monks

Re: What can effect perl startup time?
by Fletch (Bishop) on Mar 23, 2022 at 02:04 UTC

    I can’t recall the dtruss equivalent, but were I looking at this my first inclination would be to get an strace with full timing info including the length of time spent in each system call and then start comparing. You don’t say if there’s differing OS versions installed, but changes in the runtime, standard libraries, third-party but linked in libs, yadda yadda yadda . . . . Handwaving for sure but ballpark two hundredths of a second difference doesn’t strike me as completely outside the realm of what I’d consider a reasonable “expected variation”.

    Edit: and I’m basing that .02 difference as .74 vs .72 rounded

    The cake is a lie.
    The cake is a lie.
    The cake is a lie.

      Yeah, I'm inclined to believe all the software installed on the newer mac is somehow bogging things down. The older mac is basically stock with very few apps installed.

      Looks like I will have to jump through security hoops to run strace/dtruss. While I"m curious, I'm not that curious to do all that and then only find out that I have no idea what I'm looking at and going down that rabbit hole. A project for a very rainy day, I suppose.

      $PM = "Perl Monk's";
      $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
      $nysus = $PM . ' ' . $MC;
      Click here if you love Perl Monks

Re: What can effect perl startup time?
by roho (Bishop) on Mar 23, 2022 at 05:01 UTC
    Slightly OT. First, a disclaimer: I am not an English teacher nor the child of an English teacher, but 'affect' and 'effect' are two of the most commonly confused words in the English language. (Sorry - slow night here - filling the time gaps with grammatical trivia.)

    The Merriam-Webster web site offers this hint on how to distinguish between the two and use the correct one:
    Affect is usually a verb meaning "to produce an effect upon," as in "What can affect Perl startup time?"
    Effect is usually a noun meaning "a change that results when something is done or happens," as in "computers have had a huge effect on our lives."
    There are exceptions, but if you think of affect as a verb and effect as a noun, you’ll be right a majority of the time."

    "It's not how hard you work, it's how much you get done."

      Lack of sleep can effect your ability to write. See?

      $PM = "Perl Monk's";
      $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
      $nysus = $PM . ' ' . $MC;
      Click here if you love Perl Monks

        It sure can affect one's ability to write :). I've worked through many a night with diminishing returns and watched the sun rise.

        "It's not how hard you work, it's how much you get done."

        Lack of sleep can effect your ability to write. See?

        I see that you got it wrong. What's your point?

Re: What can effect perl startup time?
by nysus (Parson) on Mar 23, 2022 at 02:25 UTC

    OK, mystery solved. Seems the Comma IDE left a zombie rakudo process running after I shut it down which was eating 100% CPU. So on the newer mac I now I get: 0.34s user 0.17s system 82% cpu 0.615 total

    Which is much more inline with expectations.

    $PM = "Perl Monk's";
    $MC = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest Vicar Parson";
    $nysus = $PM . ' ' . $MC;
    Click here if you love Perl Monks

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-20 05:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found