Open Bug 1352908 Opened 8 years ago Updated 6 years ago

Optimize certain filters in the template compiler

Categories

(bugzilla.mozilla.org :: General, enhancement)

Production
enhancement
Not set
normal

Tracking

()

People

(Reporter: dylan, Unassigned)

References

(Blocks 2 open bugs)

Details

Attachments

(3 files, 1 obsolete file)

Optimize certain filters in the template compiler [% ... FILTER none %] is optimized away. There is no cost for using it. [% ... FILTER html %] is optimized to a direct call to Bugzilla::Util::html_quote, saving a method call to $stash->filter. [% ... FILTER null %] avoids a filter call and always results in ''
Attached file PR (obsolete) —
Attachment #8853835 - Flags: review?(glob)
Blocks: 1352912
Attached patch 1352908_1.patchSplinter Review
Attachment #8853835 - Attachment is obsolete: true
Attachment #8853835 - Flags: review?(glob)
Attachment #8853975 - Flags: review?(glob)
Comment on attachment 8853975 [details] [diff] [review] 1352908_1.patch Review of attachment 8853975 [details] [diff] [review]: ----------------------------------------------------------------- nice optimisation! ::: Bugzilla/Template/Directive.pm @@ +5,5 @@ > +# This Source Code Form is "Incompatible With Secondary Licenses", as > +# defined by the Mozilla Public License, v. 2.0. > + > +# This exists to implement the template-before_process hook. > +package Bugzilla::Template::Directive; i suspect this exists for a different reason. @@ +15,5 @@ > +use base qw(Template::Directive); > + > +sub filter { > + package Template::Directive; > + our ($PRETTY, $OUTPUT); i'd prefer this to be written as $PRETTY = $Template::Directive::PRETTY, same for OUTPUT
Attachment #8853975 - Flags: review?(glob) → review-
I finally got to cleaning up this code, and I've also profiled the impact it has. For 257 page visits, the difference is: without patch: # spent 2.53s (1.64+890ms) within Bugzilla::Template::Context::filter which was called 381645 times, avg 7µs/call: with patch: # spent 470ms (186+285) within Bugzilla::Template::Context::filter which was called 37008 times, avg 13µs/call:
Attachment #8853975 - Flags: review-
Attached file PR
Attached patch user-error.patchSplinter Review
Show casing the difference in the generated code
Is this still being worked on?
Flags: needinfo?(dylan)
Yeah, it was one of the things I worked on over the break. It seemed to break tests, and I was bisecting that problem. Difficult because tests take so long to run.
Flags: needinfo?(dylan)
Assignee: dylan → nobody
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: