Closed Bug 1427395 Opened 3 years ago Closed 3 years ago

Allow request_cache to be constant-folded in Bugzilla.pm

Categories

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

Production
enhancement
Not set
normal

Tracking

()

RESOLVED FIXED

People

(Reporter: dylan, Assigned: dylan)

References

(Blocks 1 open bug)

Details

(Keywords: perf)

Attachments

(1 file)

45 bytes, text/x-github-pull-request
Details | Review
We already declare request_cache() using the constant pragma. We do this because calling an xsub (briefly, a subroutine written in C) is very fast.

However, if we call request_cache() as a subroutine (and not as a class method) the perl compiler is able to constant-fold it. This means there is *no* overhead.

Over half of all calls to Bugzilla->request_cache() happen inside Bugzilla.pm,
so doing s/\$(self|_\[0\])->request_cache/request_cache/ there will result in a nice speed up.
(okay, only from 2ms to 600µs). 

Changing it in other places will require additional work, as modules are not supposed to 'use Bugzilla'
and constant folding requires the subroutine to be declared at compile time...
Attached file github pull request
Assignee: nobody → dylan
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.