neoremind commented on code in PR #16894: URL: https://github.com/apache/lucene/pull/16894#discussion_r4545649580
########## dev-tools/scripts/luceneutil_report.py: ########## @@ -0,0 +1,167 @@ +#!/usr/bin/env python3 +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +"""Formats the results of a luceneutil baseline vs candidate comparison as Markdown. + +Used by .github/workflows/run-benchmark-luceneutil.yml to write the job summary and +the pull request comment. It reads the luceneutil log and reports its final results table. +""" + +import argparse +import re +import sys +from dataclasses import dataclass +from pathlib import Path + +SIGNIFICANCE = 0.05 +SMOKE_TEST_SOURCES = {"wikimedium10k"} + +# One row of the luceneutil results table, for example: +# MedTerm 11029.12 (3.9%) 11709.36 (5.4%) 6.2% ( -3% - 16%) 0.040 +ROW = re.compile( + r"^\s*(?P<task>[A-Za-z0-9_]+)" + r"\s+(?P<base_qps>[\d.]+)\s+\(\s*(?P<base_sd>[\d.]+)%\)" + r"\s+(?P<cand_qps>[\d.]+)\s+\(\s*(?P<cand_sd>[\d.]+)%\)" + r"\s+(?P<change>-?[\d.]+)%\s+\(\s*-?\d+%\s+-\s+-?\d+%\)" + r"\s+(?P<p_value>[\d.]+)\s*$" +) + + +@dataclass(frozen=True) +class TaskResult: + task: str + base_qps: float + base_sd: float + cand_qps: float + cand_sd: float + change: float + p_value: float + + @property + def significant(self) -> bool: + return self.p_value < SIGNIFICANCE + + +def parse_results(log: str) -> list[TaskResult]: + """Returns the rows of the last results table; luceneutil prints an updated one after every iteration.""" + lines = log.splitlines() + headers = [i for i, line in enumerate(lines) if "TaskQPS" in line and "p-value" in line] + if not headers: + return [] + results: list[TaskResult] = [] + for line in lines[headers[-1] + 1 :]: + match = ROW.match(line) + if match is None: + break + results.append( + TaskResult( + task=match["task"], + base_qps=float(match["base_qps"]), + base_sd=float(match["base_sd"]), + cand_qps=float(match["cand_qps"]), + cand_sd=float(match["cand_sd"]), + change=float(match["change"]), + p_value=float(match["p_value"]), + ) + ) + return results + + +def format_table(results: list[TaskResult]) -> list[str]: + lines = [ + "| Task | Baseline QPS | Candidate QPS | Change | p-value |", + "| --- | ---: | ---: | ---: | ---: |", + ] + for r in results: + lines.append(f"| {r.task} | {r.base_qps:.2f} ± {r.base_sd:.1f}% | {r.cand_qps:.2f} ± {r.cand_sd:.1f}% | {r.change:+.1f}% | {r.p_value:.3f} |") + return lines + + +def describe_machine(args: argparse.Namespace) -> str: + cpus = f"{args.cpus} CPUs" + (f" ({args.cpu_model})" if args.cpu_model else "") + parts = [args.runner, cpus] + if args.memory_gb: + parts.append(f"{args.memory_gb} GB RAM") + if args.disk_gb: + parts.append(f"{args.disk_gb} GB disk") + if args.jdk: + parts.append(args.jdk) + parts.append(f"attempt {args.attempt}") + return ", ".join(parts) + + +def render(results: list[TaskResult], args: argparse.Namespace) -> str: + lines = [ + f"### luceneutil `{args.source}`: candidate `{args.candidate[:10]}` vs baseline `{args.baseline[:10]}`", Review Comment: A few nits on the content format to make it easier for PR authors. 1. Would it be better to make the title something like "Performance benchmark (luceneutil wikimedium1m)"? "luceneutil" alone doesn't say much to people who haven't seen the new workflow. 2. Revision links based on baseline and candidate's SHAs, they are not clickable, also better to add a compare link between the revisions, let reviewers jump to the code directly. 3. I checked the test report, it says "ubuntu-26.04-arm, 4 CPUs, attempt 1" under title, it is a bit simple. It would be better to show OS, CPU, memory, disk size as well as spec (ssd/nvme/ebs?), java version and JVM args, Most of this is already printed by the Runner info step, and for disk we could use lsblk. To keep the env info short, it can be wrapped into `<details>`. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
