Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: ModPerl: Embperl-cvs

cvs commit: embperl/test/conf startup.pl

 

 

ModPerl embperl-cvs RSS feed   Index | Next | Previous | View Threaded


richter at apache

Jul 24, 2005, 10:56 PM

Post #1 of 3 (1066 views)
Permalink
cvs commit: embperl/test/conf startup.pl

richter 2005/07/24 22:56:15

Modified: . Embperl.pm
test/conf startup.pl
Log:
- added test for preloading of Embperl pages on startup

Revision Changes Path
1.201 +12 -10 embperl/Embperl.pm

Index: Embperl.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl.pm,v
retrieving revision 1.200
retrieving revision 1.201
diff -u -r1.200 -r1.201
--- Embperl.pm 17 Jun 2005 21:14:28 -0000 1.200
+++ Embperl.pm 25 Jul 2005 05:56:15 -0000 1.201
@@ -127,8 +127,10 @@
# when called inside a Embperl Request, Execute the component only
return Embperl::Req::ExecuteComponent ($_ep_param, @_) if ($req) ;

+ $_ep_param = { inputfile => $_ep_param, param => [@_]} if (!ref $_ep_param) ;
+
local $req_rec ;
- if ($modperl)
+ if ($modperl && !exists ($_ep_param -> {req_rec}))
{
if ($modperlapi < 2)
{
@@ -139,17 +141,17 @@
$req_rec = Apache2::RequestUtil -> request ;
}
}
-
- my $rc ;
- if (!ref $_ep_param)
- {
- $rc = Embperl::Req::ExecuteRequest (undef, { inputfile => $_ep_param, param => [@_]}) ;
+ elsif (exists ($_ep_param -> {req_rec}) && defined ($_ep_param -> {req_rec}))
+ {
+ $req_rec = $_ep_param -> {req_rec} ;
}
- else
+
+ my $_ep_rc ;
{
- $rc = Embperl::Req::ExecuteRequest (undef, $_ep_param) ;
+ $_ep_rc = Embperl::Req::ExecuteRequest (undef, $_ep_param) ;
}
- return $rc ;
+
+ return $_ep_rc ;
}

#######################################################################################



1.23 +1 -1 embperl/test/conf/startup.pl

Index: startup.pl
===================================================================
RCS file: /home/cvs/embperl/test/conf/startup.pl,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -r1.22 -r1.23
--- startup.pl 22 Feb 2005 16:34:29 -0000 1.22
+++ startup.pl 25 Jul 2005 05:56:15 -0000 1.23
@@ -57,7 +57,7 @@
$testshare = "Shared Data" ;
$cp -> share ('$testshare') ;

-##Embperl::Execute ({ inputfile => "$ENV{EMBPERL_SRC}/test/html/div.htm", import => 0, input_escmode => 7 }) ;
+Embperl::Execute ({ inputfile => "$cwd/test/html/div.htm", import => 0, input_escmode => 7, req_rec => undef }) ;


1 ;




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe [at] perl
For additional commands, e-mail: embperl-cvs-help [at] perl


richter at apache

Aug 6, 2005, 5:52 PM

Post #2 of 3 (956 views)
Permalink
cvs commit: embperl/test/conf startup.pl [In reply to]

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: embperl-cvs-unsubscribe [at] perl
For additional commands, e-mail: embperl-cvs-help [at] perl


richter at apache

Aug 8, 2005, 10:12 PM

Post #3 of 3 (967 views)
Permalink
cvs commit: embperl/test/conf startup.pl [In reply to]

richter 2005/08/08 22:12:19

Modified: . Changes.pod Embperl.xs ep.h epmain.c
Embperl Object.pm
eg/web/db epwebapp.pl
test/conf startup.pl
Log:
- http headers from %http_headers_out will now also be send when the
init method of an application object return non zero (e.g. 302 for redirect).

Revision Changes Path
1.285 +6 -0 embperl/Changes.pod

Index: Changes.pod
===================================================================
RCS file: /home/cvs/embperl/Changes.pod,v
retrieving revision 1.284
retrieving revision 1.285
diff -u -r1.284 -r1.285
--- Changes.pod 7 Aug 2005 15:59:08 -0000 1.284
+++ Changes.pod 9 Aug 2005 05:12:19 -0000 1.285
@@ -1,6 +1,12 @@
=pod


+=head4 2.0rc6
+
+ - http headers from %http_headers_out will now also be send when the
+ init method of an application object return non zero (e.g. 302 for redirect).
+
+
=head4 2.0rc5 7. August 2005

- Added attribute content-type to mail:send tag (Syntax Mail).



1.59 +9 -0 embperl/Embperl.xs

Index: Embperl.xs
===================================================================
RCS file: /home/cvs/embperl/Embperl.xs,v
retrieving revision 1.58
retrieving revision 1.59
diff -u -r1.58 -r1.59
--- Embperl.xs 27 Feb 2005 20:05:47 -0000 1.58
+++ Embperl.xs 9 Aug 2005 05:12:19 -0000 1.59
@@ -128,6 +128,15 @@
RETVAL


+int
+embperl_send_http_header(pReq)
+ tReq * pReq;
+CODE:
+ RETVAL = embperl_SendHttpHeader (pReq) ;
+OUTPUT:
+ RETVAL
+
+






1.48 +1 -48 embperl/ep.h

Index: ep.h
===================================================================
RCS file: /home/cvs/embperl/ep.h,v
retrieving revision 1.47
retrieving revision 1.48
diff -u -r1.47 -r1.48
--- ep.h 31 Oct 2004 14:17:25 -0000 1.47
+++ ep.h 9 Aug 2005 05:12:19 -0000 1.48
@@ -215,50 +215,9 @@
int ExecuteReq (/*i/o*/ register req * r,
/*in*/ SV * pReqSV) ;

-#if 0
-tReq * SetupRequest (/*in*/ SV * pApacheReqSV,
- /*in*/ char * sSourcefile,
- /*in*/ double mtime,
- /*in*/ long nFilesize,
- /*in*/ int nFirstLine,
- /*in*/ char * sOutputfile,
- /*in*/ tConf * pConf,
- /*in*/ int nIOType,
- /*in*/ SV * pIn,
- /*in*/ SV * pOut,
- /*in*/ char * sSubName,
- /*in*/ char * sImport,
- /*in*/ int nSessionMgnt,
- /*in*/ tTokenTable * pTokenTable) ;
-
-void FreeRequest (/*i/o*/ register req * r) ;
-
-tFile * SetupFileData (/*i/o*/ register req * r,
- /*in*/ char * sSourcefile,
- /*in*/ double mtime,
- /*in*/ long nFilesize,
- /*in*/ int nFirstLine,
- /*in*/ tConf * pConf) ;
-
-tFile * GetFileData (/*in*/ char * sSourcefile,
- /*in*/ char * sPackage,
- /*in*/ double mtime,
- /*in*/ int bEP1Compat) ;
-
-
-tConf * SetupConfData (/*in*/ HV * pReqInfo,
- /*in*/ SV * pOpcodeMask) ;

-void FreeConfData (/*in*/ tConf * pConf) ;
-
-#endif
+int embperl_SendHttpHeader (/*i/o*/ register req * r) ;

-int ScanCmdEvalsInString (/*i/o*/ register req * r,
- /*in*/ char * pIn,
- /*out*/ char * * pOut,
- /*in*/ size_t nSize,
- /*out*/ char * * pFree) ;
-
char * LogError (/*i/o*/ register req * r,
/*in*/ int rc) ;
char * LogErrorParam (/*i/o*/ struct tApp * a,
@@ -273,12 +232,6 @@
/*in*/ int nBlockStart,
/*in*/ int nBlockSize,
/*in*/ int nBlockNo) ;
-#if 0
-int ProcessSub (/*i/o*/ register req * r,
- /*in*/ tFile * pFile,
- /*in*/ int nBlockStart,
- /*in*/ int nBlockNo) ;
-#endif
void NewEscMode (/*i/o*/ register req * r,
SV * pSV) ;




1.141 +3 -4 embperl/epmain.c

Index: epmain.c
===================================================================
RCS file: /home/cvs/embperl/epmain.c,v
retrieving revision 1.140
retrieving revision 1.141
diff -u -r1.140 -r1.141
--- epmain.c 7 Aug 2005 00:02:58 -0000 1.140
+++ epmain.c 9 Aug 2005 05:12:19 -0000 1.141
@@ -821,8 +821,7 @@



-static int SendHttpHeader (/*i/o*/ register req * r)
-
+int embperl_SendHttpHeader (/*i/o*/ register req * r)

{
epTHX_
@@ -1157,7 +1156,7 @@

if (!(r -> Config.bOptions & optEarlyHttpHeader) &&
(r -> Config.bOptions & optSendHttpHeader) && !r -> Component.Param.pOutput)
- SendHttpHeader (r) ;
+ embperl_SendHttpHeader (r) ;

if (r -> Component.Param.pOutput)
return OutputToMem (r) ;



1.18 +2 -1 embperl/Embperl/Object.pm

Index: Object.pm
===================================================================
RCS file: /home/cvs/embperl/Embperl/Object.pm,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Object.pm 8 Aug 2005 13:42:44 -0000 1.17
+++ Object.pm 9 Aug 2005 05:12:19 -0000 1.18
@@ -318,6 +318,7 @@
}
elsif ($status)
{
+ $r -> send_http_header ;
$r -> cleanup ;
print Embperl::LOG "[$$]Embperl::Object Application -> init had returned $status\n" if ($debug);
return $status ;



1.15 +0 -4 embperl/eg/web/db/epwebapp.pl

Index: epwebapp.pl
===================================================================
RCS file: /home/cvs/embperl/eg/web/db/epwebapp.pl,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- epwebapp.pl 8 Aug 2005 13:42:44 -0000 1.14
+++ epwebapp.pl 9 Aug 2005 05:12:19 -0000 1.15
@@ -757,11 +757,7 @@

my $dest = join ('&', map { $_ . '=' . $r -> Escape (ref ($params{$_})?join("\t", @{$params{$_}}):$params{$_} , 2) } keys %params) ;

- #$http_headers_out{'location'} = "show.epl?$dest";
my ($uri) = split (/\?/, $r -> param -> unparsed_uri, 1) ;
- #Apache -> request -> err_header_out('location', $r -> param -> server_addr . dirname ($uri) ."/show.epl?$dest") ;
- #Apache -> request -> err_header_out('location', 'http://www.ecos.de:8766' . dirname ($r -> param -> uri) ."/show.epl?$dest") ;
-
$http_headers_out{'location'} = $r -> param -> server_addr . dirname ($uri) ."/show.epl?$dest" ;

return 302 ;



1.26 +2 -1 embperl/test/conf/startup.pl

Index: startup.pl
===================================================================
RCS file: /home/cvs/embperl/test/conf/startup.pl,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- startup.pl 7 Aug 2005 00:52:30 -0000 1.25
+++ startup.pl 9 Aug 2005 05:12:19 -0000 1.26
@@ -52,7 +52,8 @@
{
$Embperl::initparam{debug} = 0x7fffffff ;
$Embperl::initparam{preloadfiles} = [.
- { inputfile => "$cwd/test/html/div.htm", import => 0, input_escmode => 7, req_rec => undef }
+ { inputfile => "$cwd/test/html/div.htm", input_escmode => 7, debug => 0x7fffffff },
+ { inputfile => "$cwd/test/html/EmbperlObject/sub/eposubs.htm", input_escmode => 7, debug => 0x7fffffff }
] ;
print "Preload initated\n" ;
}




---------------------------------------------------------------------
To unsubscribe, e-mail: embperl-cvs-unsubscribe [at] perl
For additional commands, e-mail: embperl-cvs-help [at] perl

ModPerl embperl-cvs RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.