Skip to content

Commit

Permalink
Update Performancebug rules and Template
Browse files Browse the repository at this point in the history
  • Loading branch information
PromiseFru committed Jan 26, 2024
1 parent e958446 commit d26e6fa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 3 deletions.
20 changes: 17 additions & 3 deletions bugbot/rules/performancebug.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
class PerformanceBug(BzCleaner):
def __init__(self):
super().__init__()
self.autofix_performance_impact = {}
self.autofix_bugs = []

def description(self):
return "[Using ML] Bugs with Missing Performance Impact"
Expand Down Expand Up @@ -65,6 +65,9 @@ def get_bugs(self, date="today", bug_ids=[]):
bug = raw_bugs[bug_id]
prob = bug_data["prob"]

if prob[1] < 0.2:
continue

results[bug_id] = {
"id": bug_id,
"summary": bug["summary"],
Expand All @@ -75,12 +78,23 @@ def get_bugs(self, date="today", bug_ids=[]):
# Only autofix results for which we are sure enough.
if prob[1] >= self.get_config("confidence_threshold"):
results[bug_id]["autofixed"] = True
self.autofix_performance_impact[bug_id] = {"cf_performance_impact": "?"}
self.autofix_bugs.append((bug_id, prob[1]))

return results

def get_autofix_change(self):
return self.autofix_performance_impact
autofix_change = {}
for bug_id, confidence in self.autofix_bugs:
autofix_change[bug_id] = {
"cf_performance_impact": "?",
}

if confidence != 1.0:
autofix_change[bug_id]["comment"] = {
"body": "The [Bugbug](https://github.com/mozilla/bugbug/) bot thinks this bug is a performance bug, but please revert this change in case of error."
}

return autofix_change


if __name__ == "__main__":
Expand Down
5 changes: 5 additions & 0 deletions configs/rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@
"confidence_threshold": 0.95,
"cc": []
},
"performancebug": {
"max_days_in_cache": 7,
"days_lookup": 7,
"confidence_threshold": 0.9
},
"stepstoreproduce": {
"max_days_in_cache": 7,
"days_lookup": 3,
Expand Down
25 changes: 25 additions & 0 deletions templates/performancebug.html
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>

0 comments on commit d26e6fa

Please sign in to comment.