Skip to content

perf: read only gerrit segments for patchsets per review - #5318

Merged
epipav merged 3 commits into
mainfrom
perf/issue-857-patchsets-gerrit
Nov 12, 2026
Merged

epipav merged 3 commits into
mainfrom
perf/issue-857-patchsets-gerrit

Conversation

@epipav

@epipav epipav commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

Summary

patchsets_per_review had a p95 of 2.3s over the last 7 days (18.8K calls). 87% of the calls come from collection pages, which show the widget on all 614 collections. Every call read all pull requests of the project or collection through pull_requests_filtered and only then kept the Gerrit changesets. Only 10 projects have Gerrit changesets (1.4M of the 40M rows in pull_requests_analyzed), so a collection like CNCF read 27M rows to return zeros.

Changes

  • New node patchsets_per_review_gerrit_segments: the segments with an enabled repository connected through a Gerrit integration.
  • New node patchsets_per_review_changesets: reads pull_requests_analyzed with the filters of pull_requests_filtered (segment, repos_to_channels), plus the Gerrit segments and the existing changeset conditions (platform = 'gerrit', patchsets present and above 0) and the date range. pull_requests_analyzed is sorted by segmentId, so the Gerrit segment filter skips the pull requests of every other project.
  • The KPI and time series nodes read the new node. Their changeset and date conditions moved into it, so each is defined once.
  • pull_requests_filtered is unchanged; other pipes still use it.

Validation

Read-only queries on production data, current pipe against this one, for 11 parameter sets:

  • Same output on all 11: CNCF and LFN collections (KPI and monthly), ONAP monthly, OpenStack KPI (average) and yearly series without dates, OpenDaylight weekly average, k8s KPI without dates, and two repos filters (a GitHub mirror URL on fd.io, a Gerrit repository on ONAP).

  • Rows read:

    Call Current New
    CNCF monthly 26.9M 1.25M
    CNCF KPI 7.6M 1.25M
    LFN monthly 5.9M 1.19M
    ONAP monthly 1.3M 0.8M
    OpenStack KPI 1.6M 1.7M

    Gerrit projects keep about the same cost. What remains for the others is the shared lookups (repos_to_channels, segments, repositories), about 0.4M to 1.2M rows.

  • The 10 segments that hold Gerrit changesets today are all in patchsets_per_review_gerrit_segments.

  • tb fmt --diff from tinybird-cli 5.22.2, the version CI installs, passes.

Deploy

Push the pipe with --force. It needs no new datasource and the insights app needs no change.

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>
@epipav

epipav commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator Author

@greptileai review

Copilot AI balanced review requested due to automatic review settings November 10, 2026 16:16
@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 10, 2026 •

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes query paths and filters for a high-traffic widget pipe; outputs were validated against production but behavior for edge segment/repo combinations should stay correct.

Overview
Refactors patchsets_per_review so collection/project requests without repos no longer scan all pull requests before keeping Gerrit rows.

It adds patchsets_per_review_gerrit_segments (segments tied to enabled Gerrit integrations) and patchsets_per_review_changesets, which reads pull_requests_analyzed directly with the same segment/channel/Gerrit/patchset/date rules that used to live on pull_requests_filtered joins. When repos is omitted, the query limits segmentId to Gerrit segments so non-Gerrit projects and collections skip their PR data.

The KPI and time-series nodes now source from patchsets_per_review_changesets only; duplicated filter clauses were removed from those nodes. pull_requests_filtered is left for other pipes.

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

@greptile-apps

greptile-apps Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable new issues were found.

Summary

patchsets_per_review.pipe reads Gerrit changesets directly and limits segment scans when repos is absent.

  • Patchset results now share one filtered changeset query.

Reviews (3) · Last reviewed commit: "Merge branch 'main' into perf/issue-857-..." · Reviewed by Greptile

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.

🟡 Changes recommended

The new Gerrit segment prefilter excludes previously selectable historical changesets from explicit-repository requests when the segment’s last Gerrit repository is disabled or deleted, changing KPI and time-series results.

1 open issue
What changed in this PR

Optimizes the Tinybird patchsets_per_review widget by restricting scans to Gerrit segments, reducing unnecessary reads for projects and collections.

Changes:

  • Adds a segment lookup based on enabled Gerrit repositories.
  • Centralizes changeset, repository, and date filters in a shared node.
  • Routes KPI and time-series calculations through that node, leaving pull_requests_filtered unchanged.
File Description
services/​libs/​tinybird/​pipes/​patchsets_per_review.pipe Adds Gerrit segment pruning and shared changeset filtering for both aggregations.

Review effort: Balanced

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

epipav commented Nov 11, 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 were identified for the Gerrit-specific scan optimization.

No open issues 🎉

1 resolved since last review

Review effort: Balanced

Copilot AI balanced review requested due to automatic review settings November 12, 2026 10:30
@epipav
epipav merged commit 5711494 into main Nov 12, 2026
16 checks passed
@epipav
epipav deleted the perf/issue-857-patchsets-gerrit branch November 12, 2026 10:31

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 were identified for the Gerrit segment-pruning and shared-filter changes.

No open issues 🎉

Review effort: Balanced

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants