develooper Front page | perl.perl5.porters | Postings from October 1999

Re: perlthread.pod -- First draft of thread docs

From:
Jason Arnold
Date:
October 22, 1999 16:49
Subject:
Re: perlthread.pod -- First draft of thread docs
Message ID:
3810F845.CF8C01AF@t-three.com
Two things:

1)  I assume the cavet still exists that locks don't dictatorially lock still
exists.  If so, it's probably wise to mention that (unless I was completely
asleep and missed the warning).

2)  Are threads still beta?  They still leak (at least in Linux (2.2.5) with Perl
5.005_62) memory, although I'm quite pleased with the CPU overhead (kudos whoever
worked on them).  I suspect that it may be both perl and linux related at it
leaks less under 5.005.62 than 5.005_03 and less with a 2.2.13 kernel than a
2.2.5 kernel.  People should at least be warned that, as the header says, "There
be dragons here..."

I.e. see below example that leaks about a MB/hour (leaks with join also, but for
my uses, detach is preferrable)...

#!/usr/bin/perl

use Config;

# Go threaded...
 $Config{usethreads} or die "Recompile Perl with thread support...\n";
 use Thread;

# Declare Threaded Subs...
 sub ScanChildren  {
  # Persistant values for children...

  while (1) {
   my $aqThr = new Thread \&AnalyzeQuery;
   $aqThr->detach();

   my $aiThr = new Thread \&AnalyzeInsert;
   $aiThr->detach();

   my $auThr = new Thread \&AnalyzeUpdate;
   $auThr->detach();

   sleep(2);
  }
 }

 sub AnalyzeQuery  {
  use attrs qw(locked);
  my $foo = 1;

 }

 sub AnalyzeInsert  {
  use attrs qw(locked);
  my $foo = 1;

 }

 sub AnalyzeUpdate  {
  use attrs qw(locked);
  my $foo = 1;

 }

# End initialization / declaration

 # Start up main child monitor thread...
 $sc_thr = new Thread \&ScanChildren;
 $sc_thr->detach();

while(1){}




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About