From ac3efc7ece5f05bcba2c5da41c8abb6e44d277bd Mon Sep 17 00:00:00 2001 From: "mkanat%bugzilla.org" Date: Tue, 7 Aug 2012 09:45:41 +0000 Subject: [PATCH] Bug 778631: use a persistent Template::Provider to avoid recompiling templates between page loads on mod_perl r=dkl, a=LpSolit git-svn-id: svn://10.0.0.236/trunk@264121 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/webtools/bugzilla/.bzrrev | 2 +- mozilla/webtools/bugzilla/Bugzilla/Template.pm | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/mozilla/webtools/bugzilla/.bzrrev b/mozilla/webtools/bugzilla/.bzrrev index b9064891dab..dd7d0e60080 100644 --- a/mozilla/webtools/bugzilla/.bzrrev +++ b/mozilla/webtools/bugzilla/.bzrrev @@ -1 +1 @@ -8331 \ No newline at end of file +8332 \ No newline at end of file diff --git a/mozilla/webtools/bugzilla/Bugzilla/Template.pm b/mozilla/webtools/bugzilla/Bugzilla/Template.pm index 87c8696b746..4bc2c32e633 100644 --- a/mozilla/webtools/bugzilla/Bugzilla/Template.pm +++ b/mozilla/webtools/bugzilla/Bugzilla/Template.pm @@ -40,6 +40,10 @@ use constant FORMAT_3_SIZE => [19,28,28]; use constant FORMAT_DOUBLE => '%19s %-55s'; use constant FORMAT_2_SIZE => [19,55]; +# Use a per-process provider to cache compiled templates in memory across +# requests. +our $shared_provider; + # Pseudo-constant. sub SAFE_URL_REGEXP { my $safe_protocols = join('|', SAFE_PROTOCOLS); @@ -603,6 +607,10 @@ sub create { COMPILE_DIR => bz_locations()->{'template_cache'}, + # Don't check for a template update until 1 hour has passed since the + # last check. + STAT_TTL => 60 * 60, + # Initialize templates (f.e. by loading plugins like Hook). PRE_PROCESS => ["global/variables.none.tmpl"], @@ -973,6 +981,8 @@ sub create { 'default_authorizer' => new Bugzilla::Auth(), }, }; + $shared_provider ||= Template::Provider->new($config); + $config->{LOAD_TEMPLATES} = [ $shared_provider ]; local $Template::Config::CONTEXT = 'Bugzilla::Template::Context';