Optimize Bugzilla->active_custom_fields() for CPU and memory usage
Categories
(bugzilla.mozilla.org :: Extensions, defect, P1)
Tracking
()
People
(Reporter: jdm, Assigned: dylan)
References
Details
(Keywords: leave-open)
Attachments
(5 files)
Reporter | ||
Comment 1•6 years ago
|
||
More specifically, I receive the following behaviour consistently when running my script that fetches data for releases 10 -> 65:
10->16: 200 OK
17: 502 Bad Gateway
This is preventing me from creating the reports that link to from the Firefox release notes.
Assignee | ||
Updated•6 years ago
|
Reporter | ||
Comment 2•6 years ago
|
||
Works: https://bugzilla.mozilla.org/rest/bug?username=josh%40joshmatthews.net&status=RESOLVED&apikey=[secret]&target_milestone=Firefox+16&target_milestone=mozilla16&include_fields=id%2Cassigned_to
Broken: https://bugzilla.mozilla.org/rest/bug?username=josh%40joshmatthews.net&status=RESOLVED&apikey=[secret]&target_milestone=Firefox+17&target_milestone=mozilla17&include_fields=id%2Cassigned_to
Assignee | ||
Comment 3•6 years ago
|
||
Something about the bad queries is using a huge amount of memory.
Worse, the allocations are coming from the mysqlclient C code.
I'm working out a fix.
Assignee | ||
Comment 4•6 years ago
|
||
I have found where the memory grows -- it's not in the mysqlclient after all, but is related to custom fields.
Assignee | ||
Comment 5•6 years ago
•
|
||
Each call to Bugzilla->active_custom_fields()
uses between 1600 kb to 1800 kb of memory per call. This memory is not leaked -- it is returned when the request cache is cleaned up, but it grows to the number of bugs returned in the request.
Further investigation shows it isn't active_custom_fields()
itself, but rather the hook that adds tracking flags.
Immediate-ish remediation for this would be bumping the max memory limit up a bit -- 3G instead of 2G may be sufficient.
Quick remediation would passing skip_extensions
to Bugzilla->active_custom_fields()
when include_fields
doesn't include any tracking flags.
The most correction remediation would be making Tracking Flags extension not cache so aggressively.
Assignee | ||
Comment 6•6 years ago
|
||
josh:
Do you have an immediate need for those APIs to work? If that is the case I can direct ops to drastically increase the memory limits until I can get a code fix out.
Assignee | ||
Comment 7•6 years ago
|
||
dkl: Any idea how we could leverage filter_wants()
to tell if the user actually wants tracking flags, without first loading the list of tracking flags? Perhaps a regex?
Reporter | ||
Comment 8•6 years ago
|
||
I will need the APIs to work in two weeks, but I can wait until then.
Assignee | ||
Comment 9•6 years ago
|
||
Ok, it will definitely work by then. I hope it works by monday.
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 10•6 years ago
|
||
script I used for collecting information.
Assignee | ||
Comment 11•6 years ago
|
||
A few runs of the attached script:
DB<7> p main::cache_size()
filter_wants = 68
Bugzilla::Component,9 = 545
Bugzilla::User,302720 = 665
Bugzilla::Bug,_,_ = 2003
DB<8> c
Bugzilla::Extension::TrackingFlags::active_custom_fields(/app/extensions/TrackingFlags/Extension.pm:291):
291: my ($self, $args) = @_;
DB<8> p main::cache_size()
Bugzilla::Component,149 = 662
Bugzilla::User,269762 = 665
Bugzilla::Bug,_,_ = 2120
it seems like this might be the problem
Assignee | ||
Comment 12•6 years ago
|
||
Here's some more debugging info, counting the number and size of objects in memory over time.
https://gist.github.com/dylanwh/ae8c37963cc146643e24ac0eb95c10e9
Need to think on this some more.
Assignee | ||
Comment 13•6 years ago
|
||
Well, there's the problem. We have 37,053 Bugzilla::Extension::TrackingFlags::Flag::Value
objects allocated after the a few requests, and there are only 3,861 in the database.
Assignee | ||
Comment 14•6 years ago
|
||
Assignee | ||
Comment 15•6 years ago
|
||
Reporter | ||
Comment 16•6 years ago
|
||
Is there a chance this will be fixed this week? The next release is on the 28th.
Assignee | ||
Comment 17•6 years ago
|
||
Absolutely, the two patches fix everything
Assignee | ||
Comment 18•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Updated•6 years ago
|
Assignee | ||
Comment 19•6 years ago
|
||
Assignee | ||
Updated•6 years ago
|
Updated•5 years ago
|
Description
•