.... all i'm saying is he shouldn't think Perl threads will make it go faster

That is not all you said. You very clearly and emphatically said far more than that. And what you actually did say is utterly wrong!

.... he cannot gaurantee his multicore system will split the Perl threads between cores..

Remove the word "Perl" from that sentence and you have something that can be said about any kernel threads, regardless of source language or OS. This is NOT a limitation of Perls ithreads.

Or of threading. The exact (corrected) statement can be made about processes (forking) also. All that preemptive multitasking and kernel threading guarentees is that if there is a core available and a thread ready to run, then that thread will run on that core. Regardless of whether that thread is a part of a process that already has another thread running on another core.

In other words, your sentence is meaningless.

in all likelyhood, it will be run in the same core,

This statement is so wrong, so cockeyed; that it almost defies refutation.

Wrong! There is no way to draw any such conclusion in isolation. Which core of a multi-core system any given thread will run next is entirely dependant upon what else is running on the system; and what their current run states are.

meaning both his threads will share a single execution pointer..... the pointer can't be in 2 places at the same time

Again, utterly, completely wrong. Even on a single core system, each thread has its own EXECUTION POINTER--and STACK POINTER; and BASE POINTER; and every other register! When the kernel executes a context switch; it saves a complete copy of the current threads execution context, and restores that of the next thread chosen to run.

In a multi-core system, each core will be populated with the execution context of one of the threads currently eligable to run.

...if you have a code snippet that shows you how to force a Perl process to split it's execution across multiple cores, i would like to see it.... i could learn something

There is simply no need to "force a Perl process to split it's execution across multiple cores". It happens whether you like it or not. Indeed, the only way to prevent it is to set the Affinity mask, and that is not trivially available to Perl.

..... i don't know how many times this has been argued.... but Perl threads actually slow you down on a single cpu machine...

Again you make a completely meaningless sweeping generalisation. It really depends what you are doing.

This takes 10 seconds to run:

c:\test>perl -e"$t=time; sleep 5; sleep 5; print time - $t" 10

Whereas this only takes 5 seconds:

c:\test>perl -Mthreads -e"$t=time;async{sleep 5}->detach;sleep 5;print + time-$t" 5

If those sleeps represent any IO-bound processing, the result is a speedup even on a single-core system.

but i'm just advising him

Wrongly! Grossly and blatently

.. Perl Threads and multi-core CPUs discusses the pitfalls

And you apparently do not understand the discussion.


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 PCW It is as I've been saying!(Audio until 20090817)

In reply to Re^6: Standard way to convert timezone in multithreaded script by BrowserUk
in thread Standard way to convert timezone in multithreaded script by whale2

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.