in reply to Re^17: Strange memory leak using just threads (forks.pm)
in thread Strange memory leak using just threads

Did you actually read the examples I gave in my post before last?

To summarise:

All of this seems pretty clear from my post before last. To arrive at your interpretation on my intent seems hard.


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
  • Comment on Re^18: Strange memory leak using just threads (forks.pm)

Replies are listed 'Best First'.
Re^19: Strange memory leak using just threads (forks.pm)
by zwon (Abbot) on Sep 23, 2010 at 12:06 UTC

    Let me quote:

    And the tests are not correct BTW. Time required for creating new thread depends on the size of all existing variables.
    Yes. That is an annoying detail of the ithreads implementation. But, it is quite easy to avoid; you just spawn your workers early, and have them require rather than use what they (individually) need.

    So, if worker threads require some heavy module, you have to use it before starting these threads (and I don't mean cases where you need just single worker thread), and it may seriously increase worker threads startup time, and it is not easy to avoid.

      Yes. And if every worker fork needs to modify 1 bit on every 4x page of 1 GB of shared data, it's gonna take forever.

      You show me your use-case, and I'll show you mine.

        And if every worker fork needs to modify 1 bit on every 4x page of 1 GB of shared data, it's gonna take forever.

        Rubbish

        use strict; use warnings; use 5.010; use Time::HiRes qw(time); my $data = 'x' x 500_000_000; my $t = time; $data =~ tr/x/y/; say time - $t; __END__ 0.469923973083496
        use strict; use warnings; use 5.010; use Time::HiRes qw(time); my $data = 'x' x 500_000_000; my $t = time; unless (fork) { $data =~ tr/x/y/; exit; } wait; say time - $t; __END__ 0.765344142913818
        use strict; use warnings; use 5.010; use threads; use Time::HiRes qw(time); my $data = 'x' x 500_000_000; my $t = time; threads->create( sub { $data =~ tr/x/y/; } )->join; say time - $t; __END__ 1.29563307762146