Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Because microseconds add up: if you waste one microsecond on each record and process a million records, that is one whole second wasted right there, which is certainly "human-perceptible" in and of itself. As Ben Franklin famously wrote in Poor Richard's Almanac: (and I am probably misquoting from memory)

"Beware little expenses; a small leak will sink a great ship."

String/value type conversions can easily take enough time to cause significant problems, and the Tcl community has a significant problem with this because in Tcl, "Everything Is A String" and the interpreter does extensive tricks to make those semantics acceptably fast on modern hardware — if the code cooperates, otherwise you get what they call "shimmering" or repeated type conversions. There is an example on that page (in Tcl) with the benchmarks "left as an exercise for the reader". The same problem is less severe in Perl, because large structures do not normally have string representations in Perl and numbers that fit in a machine integer can be translated quickly, but you deceive yourself if you claim that it does not exist.

Boxing/unboxing strings between the PV slot of an SV and raw C char * strings should be (almost) free in perl, but wrapping a C string into an SV is not free if a new SV must be allocated. Memory allocators are complex, despite an extreme level of optimization, and take significant time in even the best cases: several microseconds for each call to allocate memory has been typical in my experiments, with worst cases of many milliseconds if the system suspends the task and swaps a page. Worse, in modern systems, malloc can return quickly, but the first access instead causes a page fault, producing outlier measurements that confound profiling.

None of this is new. Lisp programmers, working in one of the oldest languages still in use, have long had the simple advice "avoid consing in an inner loop" that expresses this exact problem.

In reply to Re^2: Why not perl have raw/native type by jcb
in thread Why not perl have raw/native type by xiaoyafeng

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (8)
    As of 2020-04-05 13:23 GMT
    Find Nodes?
      Voting Booth?
      The most amusing oxymoron is:

      Results (34 votes). Check out past polls.