mirror of
https://github.com/Comfy-Org/Comfy-PR.git
synced 2026-11-04 23:37:33 +00:00
[PR #203] [MERGED] perf: fix CPU spike — add early $match before $unwind in CNRepos pipeline #201
Labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Comfy-Org/Comfy-PR#201
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Comfy-Org/Comfy-PR/pull/203
Author: @snomiao
Created: 4/24/2026
Status: ✅ Merged
Merged: 4/24/2026
Merged by: @snomiao
Base:
main← Head:perf/fix-cnrepos-cpu-spike📝 Commits (4)
3612970perf: fix CPU spike — add early $match before $unwind in CNRepos pipeline4ea4709fix: remove pullRequestMessage index — values exceed B-tree key size limit1f7c609fix: surface index build failures via console.error instead of silencing79c13bafix: use non-sparse index on GithubActionUpdateTask.error📊 Changes
3 files changed (+17 additions, -0 deletions)
View changed files
📝
src/CNRepos.ts(+8 -0)📝
src/GithubActionUpdateTask/GithubActionUpdateTask.ts(+6 -0)📝
src/analyzePullsStatus.ts(+3 -0)📄 Description
Summary
comfy-pr.CNReposreads → 737 ops × avg 5.49 min = 67.44 CPU-hours in 10.5h window;Uses Index: NobaseCRPullStatusPipeline()scanned all CNRepos docs,$unwinded everycrPulls.dataentry, then filtered — processing everything before discarding irrelevant documentsFixes:
$match { crPulls.data: { $elemMatch: { "comments.state": "ok" } } }before$unwindto skip repos with no fetched PR commentscrPulls.data.comments.state(scalarTaskfield — usingcomments.datawould fail with "Cannot index parallel arrays")GithubActionUpdateTask.errorand.pullRequestMessage(Performance Advisor flagged 4310-doc regex scans at 0.42/hr)Test plan
idx_crpulls_comments_stateindex builds successfully in Atlas (no "parallel arrays" error)/detailspage still renders correctly with the filtered pipelineanalyzePullsStatus()still returns same data (the post-$unwind.match({ "crPulls.data.comments.data": { $exists: true } })is kept as safety net)Investigation Evidence
Atlas Query Profiler (2026-04-23 22:00 JST → 2026-04-24 08:30 JST):
Actual query logged:
aggregate CNRepos → $set → $unwind "$crPulls.data" → $match → ...(Num Yields: 5,043, Uses Index: No)Reviewed by Gemini 2.5 Flash ✅, Gemini 2.5 Pro ✅ (flagged parallel-array index issue → fixed), Codex gpt-5.4 ✅
🤖 Generated with Claude Code
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.