Closed
Bug 576670
Opened 14 years ago
Closed 14 years ago
Optimize Search.pm's "init" method for being called many times in a loop
Categories
(Bugzilla :: Query/Bug List, enhancement)
Tracking
()
RESOLVED
FIXED
Bugzilla 4.2
People
(Reporter: mkanat, Assigned: mkanat)
References
Details
Attachments
(1 file, 2 obsolete files)
15.29 KB,
patch
|
mkanat
:
review+
|
Details | Diff | Splinter Review |
So, I'm working on the "bz-search-test" bug, and when it's done, it's going to run about 60 million tests. A lot of these tests involve creating a Bugzilla::Search object, and it turns out that since we don't do this many times in a loop inside of Bugzilla, it's never been optimized very well. There are a lot of things to optimize that my profiler shows up.
Assignee | ||
Comment 1•14 years ago
|
||
Okay, this makes my search test run 3x-4x faster. Here's an explanation of the optimizations: * Bugzilla->get_fields was the largest time-taker in init(). Bugzilla->fields is a better get_fields that does caching. In the future, it can be enhanced to accept more of the arguments that get_fields takes. It also optionally returns things as a hash, since even doing "map { $_->id => $_ }" on fields was showing up as a significant time-taker in my profiles. * Calling $template->process in Bugzilla::Error was slow. Tests really don't care about error text. In fact, they'd rather not know it, because they don't want the localized version, if they're going to check something about the error. So I added a new error mode for xt/search.t, called ERROR_MODE_TEST, that just dumps all the error information. * Generating the Traceback for errors was slow, so now we only do it if we're a CodeError and we're actually going to be using the traceback. * Calling $user->groups_as_string was slow, because of the "map { $_->id }" on group objects. So now I cache the group ids separately. * I noticed that bz_locations was getting called a lot, and it's really a constant, so I Memoize'd it. This is safe to do because its contents will never change, even under mod_perl. * There's a || 0 in one place to stop a warning that happens when passing in an invalid value. * %chart_fields in init() now just has the contents of Bugzilla->fields, and I pass that along and use the objects in the search functions. * Calling login_to_id over and over for the same few users was slow, so I cache its info now.
Assignee: query-and-buglist → mkanat
Status: NEW → ASSIGNED
Attachment #455819 -
Flags: review?(bugzilla)
Assignee | ||
Comment 2•14 years ago
|
||
I'm going to re-work this patch slightly so that the test can go in first, and then this. That way, the test can still make 4.0, and the optimizations will make 4.2.
No longer blocks: bz-search-test
Depends on: bz-search-test
Assignee | ||
Comment 3•14 years ago
|
||
Since this now depends on the search test (and the search test proves that it works just fine), I can grant myself review as the Search.pm owner for 4.2 and check it in once the test is checked in.
Attachment #455819 -
Attachment is obsolete: true
Attachment #455975 -
Flags: review+
Attachment #455819 -
Flags: review?(bugzilla)
Assignee | ||
Updated•14 years ago
|
Attachment #455975 -
Flags: review+ → review?(bugzilla)
Comment on attachment 455975 [details] [diff] [review] v2 r=glob
Attachment #455975 -
Flags: review?(bugzilla) → review+
Assignee | ||
Updated•14 years ago
|
Flags: approval+
Assignee | ||
Comment 5•14 years ago
|
||
Committing to: bzr+ssh://bzr.mozilla.org/bugzilla/trunk/ modified Bugzilla.pm modified Bugzilla/Constants.pm modified Bugzilla/Error.pm modified Bugzilla/Field.pm modified Bugzilla/Search.pm modified Bugzilla/Template.pm modified Bugzilla/User.pm modified xt/lib/Bugzilla/Test/Search.pm Committed revision 7314.
Status: ASSIGNED → RESOLVED
Closed: 14 years ago
Resolution: --- → FIXED
Assignee | ||
Comment 6•14 years ago
|
||
Here's what got checked in--I had to fix a bit of bitrot on checkin. Carrying forward r+.
Attachment #455975 -
Attachment is obsolete: true
Attachment #456515 -
Flags: review+
You need to log in
before you can comment on or make changes to this bug.
Description
•