richter 2005/08/06 17:52:30
Modified: . Changes.pod Embperl.pm Embperl.pod epinit.c
podsrc Config.spod
test/conf startup.pl
Log:
- Added preloadfiles parameter to %initparam, which allows to
preload files in the parent process, when running under mod_perl.
See perldoc Config.pod for details.
Revision Changes Path
1.282 +3 -0 embperl/Changes.pod
Index: Changes.pod
===================================================================
RCS file: /home/cvs/embperl/Changes.pod,v
retrieving revision 1.281
retrieving revision 1.282
diff -u -r1.281 -r1.282
--- Changes.pod 7 Aug 2005 00:02:57 -0000 1.281
+++ Changes.pod 7 Aug 2005 00:52:29 -0000 1.282
@@ -5,6 +5,9 @@
- Added attribute content-type to mail:send tag (Syntax Mail).
Patch from Axel Beckert.
+ - Added preloadfiles parameter to %initparam, which allows to
+ preload files in the parent process, when running under mod_perl.
+ See perldoc Config.pod for details.
- Fixed unresolved symbol when compiling under SuSE 9.3 (because SuSE
compiles Apache 2 in maintainer mode)
- Fixed strange output when Perl code inside of [$ sub $] returns
1.204 +27 -1 embperl/Embperl.pm
Index: Embperl.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl.pm,v
retrieving revision 1.203
retrieving revision 1.204
diff -u -r1.203 -r1.204
--- Embperl.pm 7 Aug 2005 00:02:58 -0000 1.203
+++ Embperl.pm 7 Aug 2005 00:52:29 -0000 1.204
@@ -1,7 +1,7 @@
###################################################################################
#
-# Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh
www.ecos.de
+# Embperl - Copyright (c) 1997-2004 Gerald Richter / ecos gmbh
www.ecos.de
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
@@ -113,6 +113,7 @@
tie *Embperl::LOG, 'Embperl::Log' ;
+
1 ;
#######################################################################################
@@ -193,6 +194,31 @@
#######################################################################################
+
+sub PreLoadFiles
+
+ {
+ my $files = $initparam{preloadfiles} ;
+ delete $initparam{preloadfiles} ;
+
+ if ($files && ref $files eq 'ARRAY')
+ {
+ foreach my $file (@$files)
+ {
+ if (ref $file)
+ {
+ Execute ({%$file, import => 0}) ;
+ }
+ else
+ {
+ Execute ({inputfile => $file, import => 0}) ;
+ }
+ }
+ }
+ }
+
+#######################################################################################
+
package Embperl::Req ;
#######################################################################################
1.93 +4 -2 embperl/Embperl.pod
Index: Embperl.pod
===================================================================
RCS file: /home/cvs/embperl/Embperl.pod,v
retrieving revision 1.92
retrieving revision 1.93
diff -u -r1.92 -r1.93
--- Embperl.pod 6 Aug 2005 21:47:37 -0000 1.92
+++ Embperl.pod 7 Aug 2005 00:52:29 -0000 1.93
@@ -1509,8 +1509,10 @@
options are useful for development where it doesn't matter if the
request takes a little bit longer, but on a heavily-loaded server they
should be disabled.
-Additionally the options L<optDisableChdir>, L<optDisableHtmlScan>,
-L<optDisableCleanup> have consequences for the performance.
+
+Preloading of page can save memory, because preloaded page can be
+shared between child processes. See L<"perldoc Config"|"Config.pod">
+for more details.
Also take a look at B<mod_perl_tuning.pod> for general ideas about
performance.
1.30 +3 -1 embperl/epinit.c
Index: epinit.c
===================================================================
RCS file: /home/cvs/embperl/epinit.c,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -r1.29 -r1.30
--- epinit.c 7 Aug 2005 00:02:58 -0000 1.29
+++ epinit.c 7 Aug 2005 00:52:29 -0000 1.30
@@ -1,6 +1,6 @@
/*###################################################################################
#
-# Embperl - Copyright (c) 1997-2005 Gerald Richter / ecos gmbh
www.ecos.de
+# Embperl - Copyright (c) 1997-2004 Gerald Richter / ecos gmbh
www.ecos.de
#
# You may distribute under the terms of either the GNU General Public
# License or the Artistic License, as specified in the Perl README file.
@@ -944,6 +944,8 @@
bInitDone = 1 ;
+ perl_call_pv ("Embperl::PreLoadFiles", G_DISCARD) ;
+
return rc ;
}
1.19 +26 -0 embperl/podsrc/Config.spod
Index: Config.spod
===================================================================
RCS file: /home/cvs/embperl/podsrc/Config.spod,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -r1.18 -r1.19
--- Config.spod 17 Jun 2005 21:14:28 -0000 1.18
+++ Config.spod 7 Aug 2005 00:52:30 -0000 1.19
@@ -111,6 +111,32 @@
B<NOTE:> If mod_perl is staticly linked into Apache you can not use
B<ClearModuleList>
in your httpd.conf
+=head3 Preloading pages
+
+To optimize memory usage you can preload your pages during the
initialization. If you do
+so they will get loaded into the parent process and the memory will be
shared by all
+child processes.
+
+To let Embperl preload your files, you have to supply all the filename into
the
+key B<preloadfiles> of the hash B<%initparam>, B<before> you load Embperl.
+
+Example:
+
+ BEGIN
+ {
+ $Embperl::initparam{preloadfiles} =
+ [
+ '/path/to/foo.epl',
+ '/path/to/bar.epl',
+ { inputfile => "/path/to/other.epl", input_escmode => 7 },
+ ] ;
+ }
+
+ use Embperl ;
+
+As you see for the third file, it is also possible to give a hashref and
+supply the same parameter like L<Execute> accpets (see below).
+
=head2 CGI/FastCGI
1.25 +16 -8 embperl/test/conf/startup.pl
Index: startup.pl
===================================================================
RCS file: /home/cvs/embperl/test/conf/startup.pl,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -r1.24 -r1.25
--- startup.pl 25 Jul 2005 07:01:36 -0000 1.24
+++ startup.pl 7 Aug 2005 00:52:30 -0000 1.25
@@ -43,6 +43,22 @@
} ;
+BEGIN
+ {
+ $ENV{EMBPERL_SRC} =~ /^(.*?)$/;
+ my $cwd = $1 ;
+
+ if ($ENV{TEST_PRELOAD})
+ {
+ $Embperl::initparam{debug} = 0x7fffffff ;
+ $Embperl::initparam{preloadfiles} = [
+ { inputfile => "$cwd/test/html/div.htm", import => 0,
input_escmode => 7, req_rec => undef }
+ ] ;
+ print "Preload initated\n" ;
+ }
+
+ }
+
use Embperl ;
use Embperl::Object ;
@@ -57,12 +73,4 @@
$testshare = "Shared Data" ;
$cp -> share ('$testshare') ;
-if ($ENV{TEST_PRELOAD})
- {
- Embperl::Init () if (!$mp2) ;
-
- Embperl::Execute ({ inputfile => "$cwd/test/html/div.htm", import => 0,
input_escmode => 7, req_rec => undef }) ;
- print "Preload ... ok\n" ;
- }
-
1 ;
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]