Closed Bug 518397 Opened 11 years ago Closed 11 years ago

Bugzilla::Util::get_text implementation leads to performance issues on long bugs


(Bugzilla :: Bugzilla-General, defect)

Not set





(Reporter: vitalif, Unassigned)


User-Agent:       Opera/9.80 (X11; Linux i686; U; en) Presto/2.2.15 Version/10.10
Build Identifier: 3.4.1

Bugzilla 3 performance is very poor on long bugs... :-(

The problem is:
1) Bugzilla::Template::quoteUrls() is called one time for each bug comment
2) It calls Bugzilla::Util::get_text('term', {term => 'bug'})
3) Bugzilla::Util::get_text() invokes $template->process('global/message.txt.tmpl')
4) global/message.txt.tmpl includes global/messages.html.tmpl
5) global/messages.html.tmpl includes global/variables.html.tmpl and a great [% SWITCH %].

So all these is executed for EACH bug comment. But it's unnecessary! Even if you want to leave localisation messages inside TT templates (which, strictly speaking, is not the Good Way), global/variables.html.tmpl needs to be loaded only 1 time for a page.

In our company, we solved this problem by introducing a new method get_term(), which caches terms inside the request cache. I can attach a patch. I want to discuss this, perhaps, there is the better way?

Also posting a bug about Template::Stash. (why not Template::Stash::XS?)

Other performance issues include, for example, the use of Text::Wrap, which is rather slow. Also, regular expression in Bugzilla::Template::quoteUrls() which handles $safe_protocols, could be optimized. I can also attach a patch, but these issues are minor, and the described is MAJOR.

P.S: Overall Bugzilla 3 performance is WORSE than Bugzilla 2. Probably due to increased complexity of templates. And this is despite of mod_perl VS CGI... :-(

Reproducible: Always

Steps to Reproduce:
Open a long bug (our record is 703 comments) under some profiler (for example Devel::NYTProf).
Actual Results:  
It takes approximately 20 seconds.
In Bugzilla 2.19.3, it takes 2 seconds despite of CGI... So performance :-(

Expected Results:  
Good performance, probably :_)
 165 sub quoteUrls {
 251     my $bug_word = get_text('term', { term => 'bug' });
 623 sub get_text {
 624     my ($name, $vars) = @_;
 625     my $template = Bugzilla->template_inner;
 626     $vars ||= {};
 627     $vars->{'message'} = $name;
 628     my $message;
 629     $template->process('global/message.txt.tmpl', $vars, \$message)
 630         || ThrowTemplateError($template->error());
 631     # Remove the indenting that exists in messages.html.tmpl.
 632     $message =~ s/^    //gm;
 633     return $message;
 634 }
Closed: 11 years ago
Resolution: --- → DUPLICATE
Duplicate of bug: 498309
You need to log in before you can comment on or make changes to this bug.