A large part of the growth in time cost is the way the tmps stack was being grown.

On Linux, at least some BSDs, realloc() for large allocations is handled through munmap() system call, making such allocations close to constant time. On Windows realloc() is O(size of original allocation) when the allocation can't be grown in place, since the data needs to be copied from the original allocation to the new allocation.

Before fea90cfbe1f221d50be90ca5ceb0c6c7f121e442 the tmps (or mortal) stack was being grown linearly, adding 512 entries each time the stack was grown. This dominated the execution cost for the match and io(list) no-heat cases.

With fea90cfbe1f221d50be90ca5ceb0c6c7f121e442 the tmps stack is now grown exponentially (1.5**n) like other similar allocations such as the value stack, arrays. This changes the cost to amortized constant time.

The pre-heat in each case grew the tmps stack in one big allocation, preventing the incremental growth that caused the problem.


In reply to Re: Strawberry: Both IO and global match are VERY SLOW. Unless pre-heated (but why?) by tonyc
in thread Strawberry: Both IO and global match are VERY SLOW. Unless pre-heated (but why?) by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.