SPUG: Dying Children
Dan Ebert
mathin at mathin.com
Mon Sep 20 14:47:18 CDT 2004
Ha. I think I have solved my own question so I thought I'd post what I
found out.
The child processes have a decent sized chunk of data (a hash with up to
500,000 keys). When an 'exit' is called Perl does some memory
de-allocation which takes time, hence the delay.
You can get around this by calling POSIX::_exit(0). (I know you are not
supposed to use &_ sub routines from a module :), but this was suggested
by the Camel book as a way of avoiding the execution of END blocks, so
what the hell.) It bypasses the destructor processing (and END blocks).
I think that since the child is a separate process, the system just
reclaims the memory when it dies anyway. I kept a close eye on the
memory usage with top while the script was running and I didn't see any
problems.
If anyone sees any problems I'm overlooking here I'd appreciate hearing
about them.
Thanks!
Dan.
----------------------------------------------------------
Immigration is the sincerest form of flattery.
- Unknown
----------------------------------------------------------
On Mon, 20 Sep 2004, Dan Ebert wrote:
>
> I have a script which forks of a child process to write a file while the
> parent script goes on to collect the data for the next file. I'm keeping
> track of the number of file writing children so I don't have too many
> writers at one time. I have a debug print statement right before the
> exit in the child process:
>
> print "done writing file\n";
> exit;
>
> I am noticing that there are sometimes several seconds between the print
> and the actual death of the child. This is delaying the forking of the
> next child which is slowing the script down. Has anyone seen this before?
>
> Thanks,
>
> Dan.
> ----------------------------------------------------------
> Immigration is the sincerest form of flattery.
> - Unknown
> ----------------------------------------------------------
>
>
> _____________________________________________________________
> Seattle Perl Users Group Mailing List
> POST TO: spug-list at mail.pm.org http://spugwiki.perlocity.org
> ACCOUNT CONFIG: http://mail.pm.org/mailman/listinfo/spug-list
> MEETINGS: 3rd Tuesdays, Location Unknown
> WEB PAGE: http://www.seattleperl.org
>
More information about the spug-list
mailing list