Re: sharing big global hash and objects

[prev] [thread] [next] [Date index for 2005/02/17]

From: Perrin Harkins
Subject: Re: sharing big global hash and objects
Date: 21:12 on 17 Feb 2005
On Thu, 2005-02-17 at 13:56 -0600, Barksdale, Ray wrote:
> The module containing $hash is loaded in startup.pl at boot.
> I then have a package that creates an object based on a slice of the hash:
> 
> package FooBar;
> 
> use Config qw($hash);
> 
> sub new {
> 	my ($class, $table, $field) = @_;
> 
> 	# bless hash slice instead of copying to {} and blessing
> 	my $self = bless $hash->{$table}->{$field}, $class;
> 
> 	return $self;

Does that work?  It looks really strange to me, and may be doing some
copying.

> My question is will this cause $hash (or the used parts) to come unshared
> in mod_perl2?

Probably.  There are some random factors involved here, like page
boundaries.

>  Does Perl mark the anonymous hash ($hash->{$table}->{$field})
> as being blessed into FooBar thereby causing a copy-on-write?

It does mark variables when you bless them.

Why don't you do all of this before forking?

- Perrin

sharing big global hash and objects
Barksdale, Ray 19:56 on 17 Feb 2005

Re: sharing big global hash and objects
Perrin Harkins 21:12 on 17 Feb 2005

RE: sharing big global hash and objects
Barksdale, Ray 21:51 on 17 Feb 2005

Generated at 11:21 on 20 Feb 2005 by mariachi v0.52