From 69c5836f2d3539105ef2d340186ca1978154477c Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sun, 27 Nov 2005 00:28:07 +0000 Subject: [PATCH] fixed bug from previous checkin new preloader with far more shared memory --- docs/changelog/6.x.x.txt | 2 + docs/gotcha.txt | 7 ++ lib/WebGUI.pm | 6 +- sbin/preload.perl | 176 ++++++--------------------------------- 4 files changed, 40 insertions(+), 151 deletions(-) diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 35658b7b0..b59ecffcc 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -20,6 +20,8 @@ - Added more error trapping in caching system. - Fixed some layout and control bugs in the color picker form element. - Added a simple Style Wizard. + - Updated preload.perl to automatically preload all WebGUI related modules, + which increased shared memory usage by 30%. 6.7.7 diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 324036a2b..0c90cfdf9 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -80,6 +80,13 @@ save you many hours of grief. installed make sure to update them prior to upgrading. See docs/migration.txt for details. + * You may now optionally create sbin/preload.exclude with a carriage + return seperated list of modules you don't want to be preloaded. + This file requires each line to contain exactly one full module + name such as "WebGUI::Asset::Wobject::WSClient" (without the + quotes) per line. No spaces or additional formatting can be + present. + 6.7.0 -------------------------------------------------------------------- diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index d947ae640..ba48e4c08 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -39,7 +39,6 @@ use Apache2::Const -compile => qw(OK DECLINED NOT_FOUND); use Apache2::ServerUtil (); #------------------------------------------------------------------- - sub handler { my $r = shift; my $s = Apache2::ServerUtil->server; @@ -107,11 +106,14 @@ sub contentHandler { } elsif ($session{setting}{specialState} eq "init") { return $r->print(setup()); } else { - my $output = page(); + my $output = ""; if (WebGUI::ErrorHandler::canShowPerformanceIndicators()) { my $t = [Time::HiRes::gettimeofday()]; + $output = page(); $t = Time::HiRes::tv_interval($t) ; $output =~ s/<\/title>/ : ${t} seconds<\/title>/i; + } else { + $output = page(); } WebGUI::Affiliate::grabReferral(); # process affilliate tracking request if (WebGUI::HTTP::isRedirect()) { diff --git a/sbin/preload.perl b/sbin/preload.perl index 7890eb61a..6a483909d 100644 --- a/sbin/preload.perl +++ b/sbin/preload.perl @@ -10,66 +10,12 @@ $|=1; use strict; print "\nStarting WebGUI ".$WebGUI::VERSION."\n"; -#---------------------------------------- -# Enable the mod_perl environment. -#---------------------------------------- -#use Apache::Registry (); # Uncomment this for use with mod_perl 1.0 -use ModPerl::Registry (); # Uncomment this for use with mod_perl 2.0 - - - -#---------------------------------------- -# System controlled Perl modules. -#---------------------------------------- - - - -use CGI (); CGI->compile(':all'); -use CGI::Carp (); -use CGI::Util (); -use File::Copy (); -use File::Path (); -use FileHandle (); -use POSIX (); -use URI::Escape (); -use HTTP::Request (); -use HTTP::Headers (); -use Digest::MD5 (); -use DBI (); -use HTML::Parser (); -use HTML::TagFilter (); -use HTML::Template (); -use Parse::PlainConfig (); -use Net::SMTP (); -use Log::Log4perl (); -use Tie::IxHash (); -use Tie::CPHash (); -use Time::HiRes (); -use DateTime (); -use DateTime::Format::Strptime (); -use DateTime::TimeZone (); -use Image::Magick (); -use Storable; -use XML::Simple (); -use Compress::Zlib (); -use Archive::Tar (); -use Archive::Zip (); -use IO::Zlib (); - -#### -# less commonly used so you may not want them to load into memory -### -#use SOAP::Lite (); # used only by WS Client -#use Net::LDAP (); # used only by LDAP authentication module -#use XML::RSSLite (); # used only by syndicated content wobject -#use HTML::Highlight (); # used only by search engine - - #---------------------------------------- # Database connectivity. #---------------------------------------- -#use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on low memory systems, or systems using database slaves +#use Apache::DBI (); # Uncomment if you want to enable connection pooling. Not recommended on servers with many sites, or those using db slaves. +use DBI (); DBI->install_driver("mysql"); # Change to match your database driver. @@ -78,100 +24,23 @@ DBI->install_driver("mysql"); # Change to match your database driver. # WebGUI modules. #---------------------------------------- -# core use WebGUI (); -use WebGUI::Affiliate (); -use WebGUI::Asset (); -use WebGUI::Auth (); -use WebGUI::Cache (); -use WebGUI::Config (); -use WebGUI::DatabaseLink (); -use WebGUI::DateTime (); -use WebGUI::ErrorHandler (); -use WebGUI::Form (); -use WebGUI::FormProcessor (); -use WebGUI::Group (); -use WebGUI::Grouping (); -use WebGUI::HTMLForm (); -use WebGUI::HTML (); -use WebGUI::Icon (); -use WebGUI::International (); -use WebGUI::Macro (); -use WebGUI::Mail (); -use WebGUI::MessageLog (); -use WebGUI::Operation (); -use WebGUI::Paginator (); -use WebGUI::Privilege (); -use WebGUI::Session (); -use WebGUI::Setting (); -use WebGUI::SQL (); -use WebGUI::Storage (); -use WebGUI::Style (); -use WebGUI::TabForm (); -use WebGUI::URL (); -use WebGUI::User (); use WebGUI::Utility (); - -# help -#use WebGUI::Help::Asset_Article (); -#use WebGUI::Help::Asset (); -#use WebGUI::Help::Asset_DataForm (); -#use WebGUI::Help::Asset_EventsCalendar (); -#use WebGUI::Help::Asset_HttpProxy (); -#use WebGUI::Help::Asset_IndexedSearch (); -#use WebGUI::Help::Asset_MessageBoard (); -#use WebGUI::Help::Asset_Poll (); -#use WebGUI::Help::Asset_Product (); -#use WebGUI::Help::Asset_SQLReport (); -#use WebGUI::Help::Asset_Survey (); -#use WebGUI::Help::Asset_SyndicatedContent (); -#use WebGUI::Help::Asset_Collaboration (); -#use WebGUI::Help::Asset_Shortcut (); -#use WebGUI::Help::Asset_WSClient (); -#use WebGUI::Help::AuthLDAP (); -#use WebGUI::Help::AuthWebGUI (); -#use WebGUI::Help::WebGUI (); - -# i18n -use WebGUI::i18n::English (); -use WebGUI::i18n::English::Asset (); -use WebGUI::i18n::English::Asset_Article (); -use WebGUI::i18n::English::Asset_Collaboration (); -use WebGUI::i18n::English::Asset_Navigation (); -#use WebGUI::i18n::English::AuthLDAP (); -use WebGUI::i18n::English::AuthWebGUI (); -use WebGUI::i18n::English::WebGUI (); -use WebGUI::i18n::English::DateTime (); -use WebGUI::i18n::English::WebGUIProfile (); - -# you can significantly reduce your memory usage by preloading the plugins used on your sites, only the most commonly used ones are preloaded by default - -# assets -use WebGUI::Asset::File (); -use WebGUI::Asset::File::Image (); -use WebGUI::Asset::Snippet (); -use WebGUI::Asset::Template (); -use WebGUI::Asset::Wobject (); -use WebGUI::Asset::Wobject::Article (); -use WebGUI::Asset::Wobject::Layout (); -use WebGUI::Asset::Wobject::Navigation (); -use WebGUI::Asset::Wobject::Collaboration (); - -# auth methods -use WebGUI::Auth::WebGUI (); -#use WebGUI::Auth::LDAP (); - -# macros -use WebGUI::Macro::AdminBar (); -use WebGUI::Macro::AssetProxy (); -use WebGUI::Macro::Extras (); -use WebGUI::Macro::FileUrl (); -use WebGUI::Macro::JavaScript (); -use WebGUI::Macro::PageUrl (); -use WebGUI::Macro::Slash_gatewayUrl (); -use WebGUI::Macro::Spacer (); -use WebGUI::Macro::StyleSheet (); - +use File::Find (); +my @modules = (); +my @excludes = (); +open(FILE,"<".$webguiRoot."/sbin/preload.exclude"); +while () { + chomp; + push(@excludes,$_); +} +close(FILE); +File::Find::find(\&getWebGUIModules, $webguiRoot."/lib/WebGUI"); +foreach my $package (@modules) { + next if (WebGUI::Utility::isIn($package,@excludes)); + my $use = "use ".$package." ()"; + eval($use); +} #---------------------------------------- @@ -180,10 +49,19 @@ use WebGUI::Macro::StyleSheet (); WebGUI::Config::loadAllConfigs($webguiRoot); - print "WebGUI Started!\n"; +#---------------------------------------- +sub getWebGUIModules { + my $filename = $File::Find::dir."/".$_; + return unless $filename =~ m/\.pm$/; + my $package = $filename; + $package =~ s/^\/data\/WebGUI\/lib\/(.*)\.pm$/$1/; + $package =~ s/\//::/g; + push(@modules,$package); +} + 1;