From 4d9383c1b7112a37f9fc5751cd2e8ecadc3f5922 Mon Sep 17 00:00:00 2001 From: Florin Bilt Date: Thu, 25 Sep 2025 16:18:49 +0300 Subject: [PATCH 1/2] Bug 1970636 - Add new fields to performance data to track OS, and OS version --- schemas/performance-artifact.json | 20 ++++++++++++++ treeherder/etl/perf.py | 27 +++++++++++++++++-- ...tum_os_name_performancedatum_os_version.py | 23 ++++++++++++++++ treeherder/perf/models.py | 3 +++ 4 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 treeherder/perf/migrations/0061_performancedatum_os_name_performancedatum_os_version.py diff --git a/schemas/performance-artifact.json b/schemas/performance-artifact.json index 00fde2f7186..634657eca3b 100644 --- a/schemas/performance-artifact.json +++ b/schemas/performance-artifact.json @@ -30,6 +30,23 @@ "required": ["name"], "type": "object" }, + "os_schema": { + "type": "object", + "properties": { + "name": { + "title": "Operating system name", + "type": "string", + "minLength": 1, + "maxLength": 50 + }, + "version": { + "title": "Operating system version", + "type": "string", + "minLength": 1, + "maxLength": 40 + } + } + }, "framework_schema": { "properties": { "name": { @@ -232,6 +249,9 @@ "application": { "$ref": "#/definitions/application_schema" }, + "os": { + "$ref": "#/definitions/os_schema" + }, "framework": { "$ref": "#/definitions/framework_schema" }, diff --git a/treeherder/etl/perf.py b/treeherder/etl/perf.py index b764c921bae..5ab59215870 100644 --- a/treeherder/etl/perf.py +++ b/treeherder/etl/perf.py @@ -34,6 +34,18 @@ def _get_application_version(validated_perf_datum: dict): return "" +def _get_os_fields(perf_datum): + """ + Try to read OS fields from the payload. Returns (name, version) or (None, None). + Supported formats: + - perf_datum["os"] = {"name": "...", "version": "..."} + """ + os_obj = perf_datum.get("os") + if isinstance(os_obj, dict): + return os_obj.get("name"), os_obj.get("version") + return None, None + + def _get_signature_hash(signature_properties): signature_prop_values = list(signature_properties.keys()) str_values = [] @@ -178,6 +190,7 @@ def _load_perf_datum(job: Job, perf_datum: dict): return application = _get_application_name(perf_datum) application_version = _get_application_version(perf_datum) + os_name, os_version = _get_os_fields(perf_datum) for suite in perf_datum["suites"]: suite_extra_properties = copy.copy(extra_properties) ordered_tags = _order_and_concat(suite.get("tags", [])) @@ -235,7 +248,12 @@ def _load_perf_datum(job: Job, perf_datum: dict): push=job.push, signature=signature, push_timestamp=deduced_timestamp, - defaults={"value": suite["value"], "application_version": application_version}, + defaults={ + "value": suite["value"], + "application_version": application_version, + "os_name": os_name, + "os_version": os_version, + }, ) if suite_datum.should_mark_as_multi_commit(is_multi_commit, datum_created): # keep a register with all multi commit perf data @@ -304,7 +322,12 @@ def _load_perf_datum(job: Job, perf_datum: dict): push=job.push, signature=signature, push_timestamp=deduced_timestamp, - defaults={"value": value[0], "application_version": application_version}, + defaults={ + "value": value[0], + "application_version": application_version, + "os_name": os_name, + "os_version": os_version, + }, ) if _test_should_gather_replicates_based_on( diff --git a/treeherder/perf/migrations/0061_performancedatum_os_name_performancedatum_os_version.py b/treeherder/perf/migrations/0061_performancedatum_os_name_performancedatum_os_version.py new file mode 100644 index 00000000000..d7c6bb43f87 --- /dev/null +++ b/treeherder/perf/migrations/0061_performancedatum_os_name_performancedatum_os_version.py @@ -0,0 +1,23 @@ +# Generated by Django 5.1.4 on 2025-09-24 12:02 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("perf", "0060_alter_performancealert_unique_together_and_more"), + ] + + operations = [ + migrations.AddField( + model_name="performancedatum", + name="os_name", + field=models.CharField(blank=True, max_length=100, null=True), + ), + migrations.AddField( + model_name="performancedatum", + name="os_version", + field=models.CharField(blank=True, max_length=100, null=True), + ), + ] diff --git a/treeherder/perf/models.py b/treeherder/perf/models.py index 7cbc59f0a7e..1088880f592 100644 --- a/treeherder/perf/models.py +++ b/treeherder/perf/models.py @@ -243,6 +243,9 @@ class PerformanceDatum(models.Model): job = models.ForeignKey(Job, null=True, default=None, on_delete=models.SET_NULL) push = models.ForeignKey(Push, on_delete=models.CASCADE) + os_name = models.CharField(max_length=100, null=True, blank=True) + os_version = models.CharField(max_length=100, null=True, blank=True) + class Meta: db_table = "performance_datum" indexes = [ From a1847b3a396b308d084b26b197f039531484474f Mon Sep 17 00:00:00 2001 From: Florin Bilt Date: Fri, 26 Sep 2025 14:13:23 +0300 Subject: [PATCH 2/2] Bug 1970636 - Add new fields to performance data to track OS, and OS version --- schemas/performance-artifact.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/schemas/performance-artifact.json b/schemas/performance-artifact.json index 634657eca3b..f89dae7a80c 100644 --- a/schemas/performance-artifact.json +++ b/schemas/performance-artifact.json @@ -37,13 +37,13 @@ "title": "Operating system name", "type": "string", "minLength": 1, - "maxLength": 50 + "maxLength": 100 }, "version": { "title": "Operating system version", "type": "string", "minLength": 1, - "maxLength": 40 + "maxLength": 100 } } },