Skip to content

perf: read only in-scope gerrit channels for patchsets per review - #5356

Open
epipav wants to merge 1 commit into
mainfrom
perf/issue-857-patchsets-projects
Open

epipav wants to merge 1 commit into
mainfrom
perf/issue-857-patchsets-projects

Conversation

@epipav

@epipav epipav commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator

Summary

patchsets_per_review has a p95 of 1.44s over the last 3 days of app traffic, above the 1s target. 81% of its calls are collections. Every call built two lookups before reading any changeset: repos_to_channels, which scans repositories FINAL three times to list the channels of every enabled repository (about 300K rows), and the Gerrit segment list from #5318 (about 90K rows). The two segmentId IN filters prune the pull request scan separately, so a collection without Gerrit still read about 250K pull request rows to return an empty result.

Changes

  • New node patchsets_per_review_gerrit_channels returns the segment and channel pairs of the enabled Gerrit repositories in the requested project or collection, with the channel variants repos_to_channels uses (URL, lowercase URL and the Gerrit q/project: form).
  • Without repos, patchsets_per_review_changesets filters on (segmentId, channel) IN those pairs. A scope without Gerrit gets an empty set and reads no pull requests.
  • Calls with repos keep the current filters.
  • patchsets_per_review_gerrit_segments is replaced by the new node.

Validation

Read-only queries on production data, rendering the live pipes and this branch and running them back to back.

  • On all 1.41M Gerrit changesets with patchsets, every changeset the current channel filter keeps also matches a Gerrit repository channel in its own segment, so the pairs keep the same rows.

  • Output identical to the live pipe on 49 parameter sets taken from the last 3 days of app traffic: collections (CNCF, finos, korg, dronecode, lf-networking, top-30-open-source-projects and others), Gerrit projects (OpenStack, onap, opendaylight, agl, fdio-llc, starlingx, zuul), KPI and series, median and average, calls without dates and the repos filter.

  • Rows read per call drop from 542K to 242K on average: collections read about 120K (were 400K to 750K) and Gerrit projects about 250K (were about 530K).

  • Seconds, fastest of 3 interleaved runs:

    Call Live This PR
    CNCF KPI 0.27 0.05
    finos KPI 0.22 0.05
    cross-platform-low-code-mobile monthly (no Gerrit) 0.24 0.06
    lf-networking monthly 0.20 0.06
    onap KPI 0.13 0.06
    opendaylight KPI 0.21 0.11
    onap monthly 0.22 0.11
    onap yearly, all time 0.32 0.11
    OpenStack KPI, all time 0.22 0.29
    All 49 cases, summed 10.18 5.00

    Single-call timings vary between runs on a shared cluster. OpenStack's all-time KPI reads 1.46M rows instead of 1.74M and measured between 0.13s and 0.41s on both versions.

  • tb fmt --diff passes.

Deploy

Pipe change only: push patchsets_per_review with --force.

Type of change

  • Bug fix
  • New feature
  • Refactor / cleanup
  • Performance improvement
  • Chore / dependency update
  • Documentation

Related issue

Refs linuxfoundation/lfx-cdp-insights-ops#857

Signed-off-by: anilb <epipav@gmail.com>
Copilot AI balanced review requested due to automatic review settings November 16, 2026 11:33
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@cursor

cursor Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

PR Summary

Low Risk
Read-only analytics pipe change with production parity checks; main risk would be incorrect filtering of Gerrit changesets, which was validated against live output.

Overview
The patchsets_per_review Tinybird pipe stops using the segment-only Gerrit filter and the broad repos_to_channels path when repos is omitted.

A new patchsets_per_review_gerrit_channels node builds in-scope (segmentId, channel) pairs for enabled Gerrit repos (project or collection), including the same URL variants repos_to_channels uses. patchsets_per_review_changesets then restricts the pull_requests_analyzed scan with (segmentId, channel) IN that set, so scopes with no Gerrit read no pull request rows. Requests with repos keep the existing segment plus repos_to_channels channel filter.

Reviewed by Cursor Bugbot for commit 23dd1a8. Bugbot is set up for automated code reviews on this repo. Configure here.

@epipav epipav added the Database and performance Created by Linear-GitHub Sync label Nov 16, 2026
@epipav

epipav commented Nov 16, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues are reported for the scoped Gerrit lookup optimization.

No open issues 🎉

What changed in this PR

Optimizes the Tinybird patchsets_per_review metric by narrowing repository lookups and pull request reads to Gerrit channels within the requested project or collection.

Changes:

  • Replaces the Gerrit segment lookup with scoped segment/channel pairs, including existing URL variants.
  • Uses those pairs when repos is absent, allowing scopes without Gerrit to skip pull request reads.
  • Preserves existing filters for requests with repos. Reported production comparisons show identical output across 49 parameter sets with lower average rows read.
File Description
services/​libs/​tinybird/​pipes/​patchsets_per_review.pipe Adds scoped Gerrit channel lookup, updates changeset filtering, and documents the optimized behavior.

Review effort: Balanced

@greptile-apps

greptile-apps Bot commented Nov 16, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge.

Summary

Speeds up patchsets_per_review by building Gerrit channel pairs only for the requested project or collection.

  • Patchset counts read only Gerrit channels in the requested scope.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Request] --> B{repos supplied?}
    B -->|Yes| C[Existing scope and repository channel filters]
    B -->|No| D[Enabled Gerrit repositories in scope]
    D --> E[Build segment and channel pairs]
    E --> F[Filter Gerrit changesets by pairs]
    C --> G[Calculate patchsets per review]
    F --> G
Loading

Reviews (1) · Last reviewed commit: "perf: scope patchsets to gerrit" · Reviewed by Greptile

@lfx-one

lfx-one commented Nov 17, 2026 •

Copy link
Copy Markdown

@epipav I'm starting review 1 of this pull request now (started 2026-11-17 20:02 UTC using review agent v0.1.34). The hourly check started this review. This usually takes a few minutes. I'll update this comment with the summary when I'm done. If there's no summary here after about 45 minutes, the review stopped: push a new commit, or post a comment that begins with a mention of me followed by re-review, to start another. For help with the review agent, see https://github.com/linuxfoundation/lfx-review-agent/issues.


Hi anilb, thanks for the PR and for the detailed validation numbers.

Summary

This pull request narrows the patchsets_per_review Tinybird pipe so that, without repos, it reads only the (segment, channel) pairs of enabled Gerrit repositories in scope. Scopes without Gerrit read no pull requests. It is a small, focused, well-validated change with no concerns.

Decision

✅ Approved

Details

Overview: The new patchsets_per_review_gerrit_channels node reproduces the channel variants of repos_to_channels (URL, lowercase URL, Gerrit q/project: form). It applies the same repository, integration and project filters, and scopes by segments_filtered or segments_filtered_by_collection. The repos path keeps the existing filters. Moving the platform, numberOfPatchsets conditions to the top of the WHERE clause does not change the result. The DCO check (the only required check) passed on the head commit. No findings were raised.

Other reviewers and CI checks: Copilot, Cursor Bugbot and Greptile also reported no issues. The merge state is behind main, with no conflicts reported.

Rule files: read AGENTS.md, .claude/rules/adr-format.md, .claude/rules/commit-workflow.md, .claude/rules/skill-guidance.md, CONTRIBUTING.md; skipped none

Questions, problems, or feedback: https://github.com/linuxfoundation/lfx-review-agent/issues

@lfx-one lfx-one left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved. The new patchsets_per_review_gerrit_channels node reproduces the channel variants of repos_to_channels (URL, lowercase URL, Gerrit q/project: form) with the same repository, integration and project filters. The repos path is unchanged, and no correctness, security or privacy issues were found.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Database and performance Created by Linear-GitHub Sync

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants