Re: Efficient pre-loading of symlinks and virtual directories
On Thu, 29 Mar 2001, Stas Bekman wrote: The latest policy is mod_perl-1.3 doesn't accept any new features and provides only bug fixes. All the development goes into 2.0. i think you mean mod_perl-1.xx :) and, its Apache::Registry that doesn't accept new features. Apache::RegistryNG and Apache::PerlRun do, unless it is something that can be provided with a subclass. new features are still accepted for mod_perl-1.xx, but some will be punted into 2.0 land. Still you can subclass Apache::PerlRun and provide your own method for the unique namespace package generation. right. would be cool to see a version of this on cpan that uses the inode stuff. and this feature can be considered as an option for 2.0's Apache::Registry.
Re: Efficient pre-loading of symlinks and virtual directories
On Mon, 26 Mar 2001, Fredrik Sjoholm wrote: It's well known that Apache::Registry will load and compile the same script multiple times when a site contains Apache::Registry scripts in mutliple directories, symlinked and aliased to different URLs (perhaps as a means of different levels of access restriction to the same scripts). An easy (and efficient) way of avoiding this is to map the virtual Apache perl module name to the underlying file's inode#, instead of its URL. As an extra bonus, this makes pre-loading scripts a breeze, because you no longer need to write a complex translation callback to map between filenames and URLs. It's a refreshing idea. Is this solution cross-platform? The latest policy is mod_perl-1.3 doesn't accept any new features and provides only bug fixes. All the development goes into 2.0. Still you can subclass Apache::PerlRun and provide your own method for the unique namespace package generation. _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://logilune.com/ http://singlesheaven.com http://perl.apache.org http://perlmonth.com/
Re: Efficient pre-loading of symlinks and virtual directories
At 16:57 29/03/2001 +0800, Stas Bekman wrote: On Mon, 26 Mar 2001, Fredrik Sjoholm wrote: An easy (and efficient) way of avoiding this is to map the virtual Apache perl module name to the underlying file's inode#, instead of its URL. As an extra bonus, this makes pre-loading scripts a breeze, because you no longer need to write a complex translation callback to map between filenames and URLs. It's a refreshing idea. Is this solution cross-platform? No, win32 has no notion of inodes and Cstat always returns 0 for the inode number, so people running under Apache::Registry there would still need to use something else to generate the namespace. However, I don't think that Apache understands win32's "shortcuts" so the original problem doesn't exist there. In any case it sure is an interesting idea, and I think it could be used elsewhere too. -- robin b. "What I like about deadlines is the lovely whooshing sound they make as they rush past." --Douglas Adams
Efficient pre-loading of symlinks and virtual directories
It's well known that Apache::Registry will load and compile the same script multiple times when a site contains Apache::Registry scripts in mutliple directories, symlinked and aliased to different URLs (perhaps as a means of different levels of access restriction to the same scripts). An easy (and efficient) way of avoiding this is to map the virtual Apache perl module name to the underlying file's inode#, instead of its URL. As an extra bonus, this makes pre-loading scripts a breeze, because you no longer need to write a complex translation callback to map between filenames and URLs. in Registry.pm, the following code: my $script_name = $path_info $uri =~ /\Q$path_info\E$/ ? substr($uri, 0, length($uri)-length($path_info)) : $uri; $script_name =~ s:/+$:/__INDEX__:; if ($Apache::Registry::NameWithVirtualHost $r-server-is_virtual) { my $name = $r-get_server_name; $script_name = join "", $name, $script_name if $name; } # Escape everything into valid perl identifiers $script_name =~ s/([^A-Za-z0-9_\/])/sprintf("_%2x",unpack("C",$1))/eg; # second pass cares for slashes and words starting with a digit $script_name =~ s{ (/+) # directory (\d?) # package's first character }[ "::" . (length $2 ? sprintf("_%2x",unpack("C",$2)) : "") ]egx; --- can be replaced with --- my ($dev,$inode) = stat(_); # get fs device and inode numbers my $script_name = "::FileAt::Dev${dev}::Inode${inode}"; # generate script name --- For increased performance and decreased memory usage, with no duplicate-loading. And easy pre-loading! (i didn't make a patch for this since the changes are so trivial, and perhaps there's a good reason for the current way of doing it that i didn't think of.) ~fredrik