I haven't ploughed through that long thread, but here are some basics that might point you in the right direction.

When a thread is created, the whole active interpreter at that point is cloned (copied) into the new thread. When a thread ends, whatever SVs it returns (either explicitly via return, or implicitly as the last statement, or for XS, whatever SVs it pushes into the stack) are cloned back into the parent thread, by the parent calling the join() method. If the return SVs are non-trivial (e.g. have been blessed into a package), then additional stuff needs to be cloned back. For example if the object is in class X and the 'X' package doesn't exist in the parent (say 'use X' was done in the child, not the parent), then the X package and all the methods in that namespace need copying back too.

What you are seeing is probably a situation where a large 'reverse clone' is being triggered by one of the SVs being returned to the parent. One possibility related to objects is the SVphv_CLONEABLE flag, which if set on the stash the object has been blessed into, triggers reverse-cloning the stash of that object.

One possible side effect of turning off SvOBJECT() on the object is that it causes the SVphv_CLONEABLE test to be skipped (that test is only done on objects) which somehow causes the the stash associated with the (now unblessed) object to be cloned.

But that's just wild speculation at the moment.

Dave.


In reply to Re: XS module in ithreads Perl much slower in threads::join after adding SvOBJECT_off by dave_the_m
in thread XS module in ithreads Perl much slower in threads::join after adding SvOBJECT_off by etj

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.