-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new rule for detecting potential performance-related bugs (#2305)
- Loading branch information
1 parent
7382d56
commit 6966638
Showing
4 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
# This Source Code Form is subject to the terms of the Mozilla Public | ||
# License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
# You can obtain one at http://mozilla.org/MPL/2.0/. | ||
|
||
from bugbot.bugbug_utils import get_bug_ids_classification | ||
from bugbot.bzcleaner import BzCleaner | ||
from bugbot.utils import nice_round | ||
|
||
|
||
class PerformanceBug(BzCleaner): | ||
def __init__(self, confidence_threshold: float = 0.9): | ||
""" | ||
Initialize the PerformanceBug class. | ||
Args: | ||
confidence_threshold: The confidence threshold for | ||
considering a bug as a performance bug. | ||
""" | ||
super().__init__() | ||
self.confidence_threshold = confidence_threshold | ||
|
||
def description(self): | ||
return "[Using ML] Bugs with Missing Performance Impact" | ||
|
||
def columns(self): | ||
return ["id", "summary", "confidence", "autofixed"] | ||
|
||
def get_bz_params(self, date): | ||
start_date, _ = self.get_dates(date) | ||
|
||
params = { | ||
"f1": "creation_ts", | ||
"o1": "greaterthan", | ||
"v1": start_date, | ||
"f2": "keywords", | ||
"o2": "nowords", | ||
"v2": "perf,topperf,main-thread-io", | ||
"f3": "cf_performance_impact", | ||
"o3": "equals", | ||
"v3": ["---"], | ||
} | ||
|
||
return params | ||
|
||
def get_bugs(self, date="today", bug_ids=[]): | ||
raw_bugs = super().get_bugs(date=date, bug_ids=bug_ids, chunk_size=7000) | ||
|
||
if len(raw_bugs) == 0: | ||
return {} | ||
|
||
bug_ids = list(raw_bugs.keys()) | ||
|
||
bugs = get_bug_ids_classification("performancebug", bug_ids) | ||
|
||
results = {} | ||
|
||
for bug_id, bug_data in bugs.items(): | ||
if not bug_data.get("available", True): | ||
# The bug was not available, it was either removed or is a | ||
# security bug | ||
continue | ||
|
||
bug = raw_bugs[bug_id] | ||
prob = bug_data["prob"] | ||
|
||
if prob[1] < 0.2: | ||
continue | ||
|
||
results[bug_id] = { | ||
"id": bug_id, | ||
"summary": bug["summary"], | ||
"confidence": nice_round(prob[1]), | ||
"autofixed": prob[1] >= self.confidence_threshold, | ||
} | ||
|
||
return results | ||
|
||
|
||
if __name__ == "__main__": | ||
PerformanceBug().run() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<p> | ||
The following {{ plural('bug is', data, pword='bugs are') }} probably performance related and {{ plural('doesn\'t', data, pword='don\'t') }} have performance impact value: | ||
</p> | ||
<table {{ table_attrs }}> | ||
<thead> | ||
<tr> | ||
<th>Bug</th> | ||
<th>Summary</th> | ||
<th>Confidence (%)</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{% for i, (bugid, summary, confidence, autofixed) in enumerate(data) -%} | ||
<tr {% if i % 2 == 0 %}bgcolor="#E0E0E0" | ||
{% endif -%} | ||
> | ||
<td> | ||
<a href="https://bugzilla.mozilla.org/show_bug.cgi?id={{ bugid }}">{{ bugid }}</a> | ||
</td> | ||
<td>{{ summary | e }}</td> | ||
<td {% if autofixed %}bgcolor="#00FF00"{% endif -%}>{{ confidence }}</td> | ||
</tr> | ||
{% endfor -%} | ||
</tbody> | ||
</table> |