http://qs1969.pair.com?node_id=1188599


in reply to Re: my versus our, why is my slower when script ends (global cleanup)
in thread my versus our, why is my slower when script ends (global cleanup)

Thank you for this enlightenment. I'm learning Perl all the time. I don't know what should be happening, why there is a difference until reading your reply. I tested with require POSIX and POSIX::_exit(0) placed at the end of the script. The MCE and MCE::Hobo modules call kill 9 when posix_exit => 1 is given for minimum consumption so not having to load POSIX before spawning workers.

use strict; use warnings; $| = 1; my $size = 2e6; my $data = [ 'AGCTCGTTGTTCGATCCA', 'GAGAGATAGATGATAGTG', 'TTTT_CCCC', 0 ]; print "begin\n"; my %barcode_hash = map { $_ => $data } 1 .. $size; print "end\n"; require POSIX; POSIX::_exit(0);

Calling POSIX::_exit(0) seems helpful for scripts making a big array or hash. Regarding MCE, it means having to call MCE::Loop->finish or $mce->shutdown explicitly so that socket handles and what not are released immediately and not linger around until the OS releases them. Regarding MCE::Shared, calling MCE::Shared->stop prior to exiting.

Thank you, Anonymous_Monk. I never thought to call POSIX::_exit(0) from the main process. That works out well. I'm going to take the next hour or so and update the few examples in reply to karlgoethebier's post. Out to the rescue for this wonderful Monk++. All credits to you++ for explaining what's going on.

Regards, Mario.

Update: Oh my. I like having the destructors run in the event omitting calling MCE::Loop->finish or $mce->shutdown. It's nice that Perl gives us the option to declare a variable global when having to construct a very big array or hash and still have destructors run.