Open
Bug 1352908
Opened 8 years ago
Updated 6 years ago
Optimize certain filters in the template compiler
Categories
(bugzilla.mozilla.org :: General, enhancement)
Tracking
()
NEW
People
(Reporter: dylan, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(3 files, 1 obsolete file)
|
2.90 KB,
patch
|
Details | Diff | Splinter Review | |
|
44 bytes,
text/x-github-pull-request
|
Details | Review | |
|
174.96 KB,
patch
|
Details | Diff | Splinter Review |
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 ''
| Reporter | ||
Comment 1•8 years ago
|
||
Attachment #8853835 -
Flags: review?(glob)
| Reporter | ||
Comment 2•8 years ago
|
||
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-
| Reporter | ||
Comment 4•8 years ago
|
||
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:
| Reporter | ||
Updated•8 years ago
|
Attachment #8853975 -
Flags: review-
| Reporter | ||
Comment 5•8 years ago
|
||
| Reporter | ||
Comment 6•8 years ago
|
||
Show casing the difference in the generated code
Is this still being worked on?
Flags: needinfo?(dylan)
| Reporter | ||
Comment 8•8 years ago
|
||
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)
| Reporter | ||
Updated•6 years ago
|
Assignee: dylan → nobody
You need to log in
before you can comment on or make changes to this bug.
Description
•