in reply to Re: Standard way to convert timezone in multithreaded script
in thread Standard way to convert timezone in multithreaded script

Thanks for your suggestion, but I found some time ago that using DateTime for parsing and manipulating timestamps is not very fast. My tests shown that it is tens times slower than combination of split() and POSIX::mktime.

I'm writing my things multithreaded to gain some speed by using several cores of CPU, so returning to DateTime would be serious step back from the performance point of view.

  • Comment on Re^2: Standard way to convert timezone in multithreaded script

Replies are listed 'Best First'.
Re^3: Standard way to convert timezone in multithreaded script
by ikegami (Patriarch) on Nov 23, 2009 at 18:14 UTC
    You've already shown that POSIX isn't thread safe in that respect. I don't know what you're expecting from us if you're dismissing the alternatives.
      Calling
      setenv("TZ","Blah-Blah",1); tzset();
      from .xs does the trick. But doing
      $ENV{TZ}='blah-blah' POSIX::tzset()
      does not.
Re^3: Standard way to convert timezone in multithreaded script
by zentara (Cardinal) on Nov 23, 2009 at 17:41 UTC
    I'm writing my things multithreaded to gain some speed by using several cores of CPU,

    ....i don't see exactly what your problem is with the timestamp....it prints out....what do you expect it to do?

    ...as far as using Perl threads to gain a performance benefit, you may be barking up the wrong tree...... Perl threads are not as solid as c pthreads, and you may actually find that threading slows you down.... if you search the nodes here, or google it, you will find that Perl threads don't give you speed thru concurrency..... in Perl the main thread gets a priority, and the time slice gets divided amoung the it's threads..... no concurrency..... just a thought before you start banging your head on the wall over thread speed ... :-)

    ...additionally, i don't think Perl has any capability to tell the system to utilize different cpu's, for each thread, that's the kernel's job


    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku
      in Perl the main thread gets a priority, and the time slice gets divided amoung the it's threads..... no concurrency..

      Sorry Zentara, but that is absolute and utter baloney.

      Be it pthreads under *nix, or native threads under Win, both are native kernel threads! As such, the will each receive their own timeslices from the kernel; and on multi-cored & multi-cpu'd machines, are eligiable to run on all cores.

      I really did think you knew better?


      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.
        .... all i'm saying is he shouldn't think Perl threads will make it go faster

        .... he cannot gaurantee his multicore system will split the Perl threads between cores....in all likelyhood, it will be run in the same core, meaning both his threads will share a single execution pointer..... the pointer can't be in 2 places at the same time and the nice value given to the main thread, will limit his total speed

        ...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

        ..... i don't know how many times this has been argued.... but Perl threads actually slow you down on a single cpu machine.... you may as well just have it all in the main script.... but on a multi-core system, on windows, it may work better..... but i'm just advising him, so he dosn't think Perl threads are some miracle speed boost thru concurrency

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


        I'm not really a human, but I play one on earth.
        Old Perl Programmer Haiku