[libcxx-commits] [libcxx] [llvm] [llvm][CI] Add metrics collection for libc++ premerge testing. (PR #152801)
via libcxx-commits
libcxx-commits at lists.llvm.org
Fri Aug 22 11:37:41 PDT 2025
================
@@ -81,6 +90,139 @@ class GaugeMetric:
time_ns: int
+ at dataclass
+class AggregateMetric:
+ aggregate_name: str
+ aggregate_queue_time: int
+ aggregate_run_time: int
+ aggregate_status: int
+ workflow_id: int
+
+
+def create_and_append_libcxx_aggregates(
+ workflow_metrics: list[JobMetrics]) -> list[JobMetrics,AggregateMetric]:
+ """
+ Find libc++ JobMetric entries and create aggregate metrics for them.
+
+ Sort the libc++ JobMetric entries by workflow id, and for each workflow
+ id group them by stages. Create an aggreate metric for each stage for each
+ unique workflow id. Append each aggregate metric to the workflow_metrics
+ list.
+
+ How aggreates are computed:
+ queue time: Time from when first job in group is created until last job in
+ group has started.
+ run time: Time from when first job in group starts running until last job
+ in group finishes running.
+ status: logical 'or' of all the job statuses in the group.
+ """
+ # Separate the jobs by workflow_id. Only look at JobMetrics entries.
+ aggregate_data = dict()
+ for job in workflow_metrics:
+ # Only want to look at JobMetrics
+ if not isinstance(job, JobMetrics):
+ continue
+ # Only want libc++ jobs.
+ if job.workflow_name != "Build and Test libc++":
+ continue
+ if job.workflow_id not in aggregate_data.keys():
+ aggregate_data[job.workflow_id] = [ job ]
+ else:
+ aggregate_data[job.workflow_id].append(job)
+
+ # Go through each aggregate_data list (workflow id) and find all the
+ # needed data
+ for ag_workflow_id in aggregate_data:
+ job_list = aggregate_data[ag_workflow_id]
+ stage1_jobs = list()
+ stage2_jobs = list()
+ stage3_jobs = list()
+ # sort jobs into stage1, stage2, & stage3.
+ for job in job_list:
+ if job.job_name.find('stage1') > 0:
+ stage1_jobs.append(job)
+ elif job.job_name.find('stage2') > 0:
+ stage2_jobs.append(job)
+ elif job.job_name.find('stage3') > 0:
+ stage3_jobs.append(job)
+
+ for job_list in [ stage1_jobs, stage2_jobs, stage3_jobs]:
+ if len(job_list) < 1:
+ # No jobs in that stage this time around.
+ continue
+
+ # Get the aggregate name.
+ ag_name = "github_libcxx_premerge_checks_"
+ if job_list[0].job_name.find('stage1') > 0:
+ ag_name = ag_name + "stage1_aggregate"
+ elif job_list[0].job_name.find('stage2') > 0:
+ ag_name = ag_name + "stage2_aggregate"
+ elif job_list[0].job_name.find('stage3') > 0:
+ ag_name = ag_name + "stage3_aggregate"
+ else:
+ ag_name = ag_name + "unknown_aggregate"
+
+ # Initialize the rest of the aggregate values
+ earliest_create = job_list[0].created_at_ns
+ earliest_start = job_list[0].started_at_ns
+ earliest_complete = job_list[0].completed_at_ns
+ latest_start = job_list[0].started_at_ns
+ latest_complete = job_list[0].completed_at_ns
+ ag_status = job_list[0].status
+
+ # Go through rest of jobs for this workflow id, updating stats
+ for job in job_list[1:]:
+ # Update the status
+ ag_status = ag_status or job.status
+ # Get the earliest & latest times
+ if job.created_at_ns < earliest_create:
+ earliest_create = job.created_at_ns
+ if job.completed_at_ns < earliest_complete:
+ earliest_complete = job.completed_at_ns
+ if job.started_at_ns > latest_start:
+ latest_start = job.started_at_ns
+ if job.started_at_ns < earliest_start:
+ earliest_start = job.started_at_ns
+ if job.completed_at_ns > latest_complete:
+ latest_complete = job.completed_at_ns
+
+ # Compute aggregate run time (in seconds, not ns)
+ ag_run_time = (latest_complete - earliest_start) / 1000000000
+ # Compute aggregate queue time (in seconds, not ns)
+ ag_queue_time = (latest_start - earliest_create) / 1000000000
+ # Append the aggregate metrics to the workflow metrics list.
+ workflow_metrics.append(
+ AggregateMetric(
+ ag_name, ag_queue_time, ag_run_time, ag_status,
+ ag_workflow_id
+ )
+ )
+ return
+
+def clean_up_libcxx_job_name(old_name: str) -> str:
----------------
cmtice wrote:
Done/
https://github.com/llvm/llvm-project/pull/152801
More information about the libcxx-commits
mailing list