Plan preview request routing scans all active pipeds

オープン
#7,087 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

  • #7088 @rootp1 による — マージされずにクローズ

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
45/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
静か
技術スタック
go
領域
api, performance

調査の方向性

pkg/app/server/grpcapi/api.go の API.RequestPlanPreview から始め、pipedStore.List の呼び出しと repository-matching ループを調べます。少数および多数の piped 数を対象とするベンチマークを追加し、その後、繰り返しのリクエストに対して、対象を絞った検索、インデックス、または上限付きキャッシュを評価します。複数の piped が一致する場合にも正しい結果を維持しながら、繰り返しのルーティングでアクティブな piped の全スキャンを回避できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

What happened:

RequestPlanPreview currently lists all enabled pipeds in the project and scans every configured repository entry in memory to find pipeds that match the requested repository remote and base branch. This makes each interactive plan preview request scale with total active piped count and repository mappings instead of the number of matching pipeds.

Summary

Plan preview request routing performs an O(number of pipeds x repositories per piped) in-memory scan for every request.

Affected Area

pkg/app/server/grpcapi/api.go, specifically API.RequestPlanPreview.

Steps to Reproduce

  1. Create a test or benchmark environment with many active pipeds in one project and repository mappings on those pipeds.
  2. Call API.RequestPlanPreview repeatedly for one repository remote and base branch.
  3. Capture allocations and latency with go test -bench or pprof.
  4. Observe that request cost grows with total piped count rather than with the matching pipeds.

What you expected to happen:

Plan preview routing should avoid a full active-piped scan on every request. Repeated routing for a repository/base-branch pair should be close to O(matches), for example via an index, bounded cache, or targeted lookup.

Expected Behaviour

Routing a plan preview request should avoid repeated full scans and should keep behavior correct when multiple pipeds match the same repository and branch.

How to reproduce it:

  1. Seed or mock thousands of enabled pipeds for one project.
  2. Give only a subset a repository entry matching the plan preview request remote and base branch.
  3. Repeatedly call RequestPlanPreview for that remote and branch.
  4. Compare latency/allocations as piped count increases.

Actual Behaviour

Each request calls pipedStore.List with only ProjectId and Disabled=false filters, then iterates through every returned piped and every repository entry until it finds matching mappings.

Technical Evidence

In pkg/app/server/grpcapi/api.go, RequestPlanPreview lists enabled pipeds for the project and then builds a repositories map by checking each p.Repositories entry against req.RepoRemoteUrl and req.BaseBranch. The code also has a TODO noting that caching may be needed to reduce database load.

Suspected Root Cause

The API layer has no repository-to-piped routing index or cache, so it must perform repository matching after fetching all enabled pipeds.

Proposed Direction

Add a focused benchmark for plan preview routing at small and large piped cardinalities, then avoid repeated full scans by adding a bounded cache or another targeted lookup for repository-to-piped matches.

Acceptance Criteria

  • A benchmark covering small and large piped counts is added.
  • Repeated plan preview routing for the same project/repository/base-branch avoids repeated full active-piped scans.
  • Correct behavior is preserved when multiple pipeds match the same repository and branch.

Environment:

  • piped version: Not applicable
  • control-plane version: Current master branch
  • Others: Not applicable
主要言語
Go
スター
1.4k
フォーク
391
平均マージ
4日 1時間
マージ済み PR(30日)
58

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

pipe-cd/pipecd のほかの issue

pipe-cd/pipecd の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。