build_perf: add commit annotations
cover build_perf: add commit annotations
STA 2025 Milestone 4: Add commit annotations to openembedded-core build_perf pages. Now loads commit annotations from https://git.yoctoproject.org/yocto-buildstats/plain/annotations.json
and inserts them into the page where necessary. Also refactored and simplified charts instantiation and template handling in general.
Alex Feyerke (1):
build_perf: add commit annotations
.../build_perf/html/measurement_chart.html | 168 ------------- scripts/lib/build_perf/html/report.html | 222 +++++++++++++++--- scripts/oe-build-perf-report | 153 +++++++++++- 3 files changed, 339 insertions(+), 204 deletions(-) delete mode 100644 scripts/lib/build_perf/html/measurement_chart.html
Signature · 1 line
2.40.1
PATCH 1/1 build_perf: add commit annotations
From: Alex Feyerke <[email protected]>
Also: refactoring and simplification of html rendering, esp. wrt. charts.
--- .../build_perf/html/measurement_chart.html | 168 ------------- scripts/lib/build_perf/html/report.html | 222 +++++++++++++++--- scripts/oe-build-perf-report | 153 +++++++++++- 3 files changed, 339 insertions(+), 204 deletions(-) delete mode 100644 scripts/lib/build_perf/html/measurement_chart.html
scripts/lib/build_perf/html/measurement_chart.html deleted +0 -168
@@ -1,168 +0,0 @@ -<script type="module"> - // Get raw data - const rawData = [ - {% for sample in measurement.samples %} - [{{ sample.commit_num }}, {{ sample.mean.gv_value() }}, {{ sample.start_time }}, '{{sample.commit}}'], - {% endfor %} - ]; - - const convertToMinute = (time) => { - return time[0]*60 + time[1] + time[2]/60 + time[3]/3600; - } - - // Update value format to either minutes or leave as size value - const updateValue = (value) => { - // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds] - return Array.isArray(value) ? convertToMinute(value) : value - } - - // Convert raw data to the format: [time, value] - const data = rawData.map(([commit, value, time]) => { - return [ - // The Date object takes values in milliseconds rather than seconds. So to use a Unix timestamp we have to multiply it by 1000. - new Date(time * 1000).getTime(), - // Assuming the array values are duration in the format [hours, minutes, seconds, milliseconds] - updateValue(value) - ] - }); - - const commitCountList = rawData.map(([commit, value, time]) => { - return commit - }); - - const commitCountData = rawData.map(([commit, value, time]) => { - return updateValue(value) - }); - - // Set chart options - const option_start_time = { - tooltip: { - trigger: 'axis', - enterable: true, - position: function (point, params, dom, rect, size) { - return [point[0], '0%']; - }, - formatter: function (param) { - const value = param[0].value[1] - const sample = rawData.filter(([commit, dataValue]) => updateValue(dataValue) === value) - const formattedDate = new Date(sample[0][2] * 1000).toString().replace(/GMT[+-]\d{4}/, '').replace(/\(.*\)/, '(CEST)'); - - // Add commit hash to the tooltip as a link - const commitLink = `https://git.yoctoproject.org/poky/commit/?id=${sample[0][3]}` - if ('{{ measurement.value_type.quantity }}' == 'time') { - const hours = Math.floor(value/60) - const minutes = Math.floor(value % 60) - const seconds = Math.floor((value * 60) % 60) - return `<strong>Duration:</strong> ${hours}:${minutes}:${seconds}, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` - } - return `<strong>Size:</strong> ${value.toFixed(2)} MB, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` - ;} - }, - xAxis: { - type: 'time', - }, - yAxis: { - name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration in minutes' : 'Disk size in MB', - type: 'value', - min: function(value) { - return Math.round(value.min - 0.5); - }, - max: function(value) { - return Math.round(value.max + 0.5); - } - }, - dataZoom: [ - { - type: 'slider', - xAxisIndex: 0, - filterMode: 'none' - }, - ], - series: [ - { - name: '{{ measurement.value_type.quantity }}', - type: 'line', - symbol: 'none', - data: data - } - ] - }; - - const option_commit_count = { - tooltip: { - trigger: 'axis', - enterable: true, - position: function (point, params, dom, rect, size) { - return [point[0], '0%']; - }, - formatter: function (param) { - const value = param[0].value - const sample = rawData.filter(([commit, dataValue]) => updateValue(dataValue) === value) - const formattedDate = new Date(sample[0][2] * 1000).toString().replace(/GMT[+-]\d{4}/, '').replace(/\(.*\)/, '(CEST)'); - // Add commit hash to the tooltip as a link - const commitLink = `https://git.yoctoproject.org/poky/commit/?id=${sample[0][3]}` - if ('{{ measurement.value_type.quantity }}' == 'time') { - const hours = Math.floor(value/60) - const minutes = Math.floor(value % 60) - const seconds = Math.floor((value * 60) % 60) - return `<strong>Duration:</strong> ${hours}:${minutes}:${seconds}, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` - } - return `<strong>Size:</strong> ${value.toFixed(2)} MB, <strong>Commit number:</strong> <a href="${commitLink}" target="_blank" rel="noreferrer noopener">${sample[0][0]}</a>, <br/> <strong>Start time:</strong> ${formattedDate}` - ;} - }, - xAxis: { - name: 'Commit count', - type: 'category', - data: commitCountList - }, - yAxis: { - name: '{{ measurement.value_type.quantity }}' == 'time' ? 'Duration in minutes' : 'Disk size in MB', - type: 'value', - min: function(value) { - return Math.round(value.min - 0.5); - }, - max: function(value) { - return Math.round(value.max + 0.5); - } - }, - dataZoom: [ - { - type: 'slider', - xAxisIndex: 0, - filterMode: 'none' - }, - ], - series: [ - { - name: '{{ measurement.value_type.quantity }}', - type: 'line', - symbol: 'none', - data: commitCountData - } - ] - }; - - // Draw chart - const draw_chart = (chart_id, option) => { - let chart_name - const chart_div = document.getElementById(chart_id); - // Set dark mode - if (window.matchMedia('(prefers-color-scheme: dark)').matches) { - chart_name= echarts.init(chart_div, 'dark', { - height: 320 - }); - } else { - chart_name= echarts.init(chart_div, null, { - height: 320 - }); - } - // Change chart size with browser resize - window.addEventListener('resize', function() { - chart_name.resize(); - }); - return chart_name.setOption(option); - } - - draw_chart('{{ chart_elem_start_time_id }}', option_start_time) - draw_chart('{{ chart_elem_commit_count_id }}', option_commit_count) -</script>
scripts/lib/build_perf/html/report.html +187 -35
265 lines not on this page · raw message
scripts/oe-build-perf-report +152 -1
181 lines not on this page · raw message
Signature · 1 line
2.40.1
Hi,
Thanks for the patch, much appreciated.
scripts/oe-build-perf-report def print_html_report(data, id_comp, buildstats): · line 434
Quoted 10 lines · Alba Herrerías via lists.openembedded.org
scripts/oe-build-perf-report +9
-0+ # Get commit annotations from Yocto’s git, + # mush them into the metadata object, + # and also output them as a POJO so eCharts can use them + + commitAnnotationsURL = 'https://git.yoctoproject.org/yocto-buildstats/plain/annotations.json' + commitAnnotationsJSON = {} + try: + response = urlopen(commitAnnotationsURL) + commitAnnotationsJSON = json.loads(response.read())
Would it be possible to load the annotations in the HTML with JavaScript when the page is loaded, so that the annotations are not “baked into” the HTML? If I was staring at build performance logs I’d want new annotations to be visible in all existing reports and not have to wait for another build perf run to complete to see them on a chart.
Thanks,
Ross
PATCH v2 1/1 build_perf: don’t bake commit annotations into html, always fetch dynamically.
From: Alex Feyerke <[email protected]>
--- scripts/lib/build_perf/html/report.html | 20 ++++++++++++++++++-- scripts/oe-build-perf-report | 13 ------------- 2 files changed, 18 insertions(+), 15 deletions(-)
scripts/lib/build_perf/html/report.html +18 -2
@@ -140,6 +140,11 @@ button:hover { max-width: 30em; text-wrap: auto; } + +.annotation-container:not(:empty) { + display: inline-block; +} + @media (prefers-color-scheme: dark) { :root { --text: #e9e8fa;
@@ -198,8 +203,8 @@ button:hover { <tr> <th>{{ item.title }}</th> {%if key == 'commit' %} - <td>{{ poky_link(item.value) }}{%if metadata.commit_annotation and metadata.commit_annotation.value %}<br>{{metadata.commit_annotation.value}}{% endif %}</td> - <td>{{ poky_link(item.value_old) }}{%if metadata.commit_annotation and metadata.commit_annotation.value %}<br>{{metadata.commit_annotation.value_old}}{% endif %}</td> + <td>{{ poky_link(item.value) }}<span class="annotation-container" data-commit="{{ item.value }}"></span></td> + <td>{{ poky_link(item.value_old) }}<span class="annotation-container" data-commit="{{ item.value_old }}"></span></td> {% elif key == 'commit_annotation' %} {% else %} <td>{{ item.value }}</td>
@@ -529,6 +534,17 @@ chartData.forEach(test => { drawChart(measurement.chart_elem_start_time_id, startTimeChartConfig) drawChart(measurement.chart_elem_commit_count_id, commitCountChartConfig) }) + + // Splice commit annotations into the table at the top of the page + if (commitAnnotations) { + document.querySelectorAll("[data-commit]").forEach((item) => { + const commitNumber = item.getAttribute("data-commit") + const matchingAnnotation = commitAnnotations[commitNumber] + if (matchingAnnotation) { + item.innerText = matchingAnnotation + } + }) + } })
scripts/oe-build-perf-report +0 -13
@@ -432,19 +432,6 @@ def print_html_report(data, id_comp, buildstats): try: response = urlopen(commitAnnotationsURL) commitAnnotationsJSON = json.loads(response.read()) - # Splice the annotations into the metadata - commit = metadata.get('commit', {}) - annotations_out = {} - - if (h := commit.get('value')) in commitAnnotationsJSON: - annotations_out['value'] = commitAnnotationsJSON[h] - - if (h := commit.get('value_old')) in commitAnnotationsJSON: - annotations_out['value_old'] = commitAnnotationsJSON[h] - - if annotations_out: - metadata['commit_annotation'] = annotations_out - metadata['commit_annotation']['title'] = "Commit annotation" except error.URLError as e: logging.debug(f"Couldn't find any commit annotations at {commitAnnotationsURL}, reason: {e.reason}.")
Signature · 1 line
2.40.1
Patchtest results for [PATCH v2] build_perf: don’t bake commit annotations into html, always fetch dynamically.
Thank you for your submission. Patchtest identified one or more issues with the patch. Please see the log below for more information:
---
Testing patch /home/patchtest/share/mboxes/v2-build_perf-don-t-bake-commit-annotations-into-html-always-fetch-dynamically..patch
FAIL: test shortlog format: Commit shortlog (first line of commit message) should follow the format "<target>: <summary>" (test_mbox.TestMbox.test_shortlog_format)
FAIL: test shortlog length: Edit shortlog so that it is 90 characters or less (currently 134 characters) (test_mbox.TestMbox.test_shortlog_length)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)
SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test CVE tag format: No new CVE patches introduced (test_patch.TestPatch.test_cve_tag_format)
SKIP: test Signed-off-by presence: No new CVE patches introduced (test_patch.TestPatch.test_signed_off_by_presence)
SKIP: test Upstream-Status presence: No new CVE patches introduced (test_patch.TestPatch.test_upstream_status_presence_format)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
---
Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this email with an explanation of why the patch should be accepted. If you believe these results are due to an error in patchtest, please submit a bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category under 'Yocto Project Subprojects'). For more information on specific failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank you!