develooper Front page | perl.ithreads | Postings from August 2002

Re: Thread-Tie-0.01

From:
Elizabeth Mattijsen
Date:
August 12, 2002 11:02
Subject:
Re: Thread-Tie-0.01
Message ID:
4.2.0.58.20020812195902.062dd3f0@mickey.dijkmat.nl
At 04:59 PM 8/12/02 +0100, Nick Ing-Simmons wrote:
> >I'm not sure I'm following you here...  Could you elaborate?
>tie @tied_array;  # 10000 elements say
>
>foreach my $value (@tied_array)  # 10000 extra SVs tied to elements
>  {
>   print $value;
>  }  # all freed here
>
>foreach my $i (0..$#tied_array)
>  {
>   my $value = $tied_array[$i];   # Just one extra SV tied to an element
>   print $value;
>  } # free'd / reused here

 From Arthur's description I got the impression that there wouldn't be any 
difference in these approaches.  Both will do a FETCH and store it in an SV 
associated with the element.  It's just that in the first case this happens 
when building the list in foreach(), the second it is when fetching it 
inside the loop.

Am I reading Arthur's explanation the wrong way then?


> >> >Apart from the huge memory leak that makes it impossible to use shared
> >> >arrays and hashes in a production environment.
> >>So let us find it.
> >   $ perl -Mthreads -Mthreads::shared -e 'my @array : shared; while (1) {
> >push( @array,1 ); pop( @array ) }'
> >will start eating away at your memory quite rigorously...  ;-)
>That will be a huge help in track it down.

Can't get much simpler than that, now can it?   ;-)


> >I'm not 100% sure with hashes, that may need involvement of multiple
> >threads.  Couldn't reproduce it as simply as above...
> >As most of it is in XS, I won't be able to help you much there...
>Just producing ways to reporoduce the problem (ideally as tests)
>is a huge help.

Will look at the hash case again.  Am quite sure it does leak also, but I 
guess I need to create a simple case...  ;-)


> >> >- threads->yield doesn't seem to yield.
> >> >This means you're burning CPU needlessly until your timeslice is over.
> >>ick - can we find something that _does_ yield?
> >You mean an OS that yields()?
>No I mean something that will cause Linux to yield usleep(1) or
>a select() with a 1ms timeout or ...

Which is what sleep(0) might do...  ok...  Will do some testing now...


Liz




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