Corion called it right!

The simplest fix is to modify:

$ref_gen_data->{'gp'}{'major_version'}, $ref_gen_data->{'gp'}{'minor_version'},

to be:

0 + $ref_gen_data->{'gp'}{'major_version'}, 0 + $ref_gen_data->{'gp'}{'minor_version'},

That change will immediately reduce the runtime (on my system) from 27 minutes to 2 seconds.

The source of the problem is that those two elements of the hash are referenced in -textvariable' clauses in Entry() elements within your GUI. This causes Tk to apply tie magic to both variables, which effectively means that every (even read) reference to these variables becomes a chain of function calls to resolve and apply the magic. As the "holder" of the magic is running on a different thread, it also involves multiple context switches. And hence, r-e-a-l-l-y s-l-o-w.

The surprising thing here is that the attached magic survives the transmission of the values of the hash elements between threads via a Thread::Queue. This appears to be by (re)design, when share magic was modified to allow the sharing of (only specially written) objects between threads.

The reason that adding 0 to the values prior to enqueuing them works, is because it forces the value into the IV slot rather than the PV slot. And it appears the magic is only applied to the PV slot.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP an inspiration; A true Folk's Guy

In reply to Re: Thread very slow by BrowserUk
in thread Thread very slow by Dirk80

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.