-
Notifications
You must be signed in to change notification settings - Fork 11
perf: only dispatch affected release targets to eval queue in compute policy target job #559
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…te policy target job
WalkthroughThe code updates the logic in the compute-policy-target-release-target-selector worker. It modifies how release targets are queried, locked, deleted, and inserted within a transaction. The selection and dispatching of release targets for evaluation now use a more targeted approach, focusing only on affected release targets. Changes
Sequence Diagram(s)sequenceDiagram
participant Worker
participant DB
participant JobDispatcher
Worker->>DB: Fetch policyTarget (no policy join)
Worker->>DB: Lock computedPolicyTargetReleaseTarget rows (FOR UPDATE NOWAIT)
Worker->>DB: Delete obsolete computedPolicyTargetReleaseTarget rows (returning deleted)
Worker->>DB: Insert new computedPolicyTargetReleaseTarget rows (onConflictDoNothing)
Worker->>DB: Query releaseTarget rows by affected IDs (using inArray)
Worker->>JobDispatcher: Dispatch evaluation jobs for affected releaseTargets
Possibly related PRs
Suggested reviewers
Poem
Tip ⚡️ Faster reviews with caching
Enjoy the performance boost—your workflow just got faster. 📜 Recent review detailsConfiguration used: .coderabbit.yaml 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
⏰ Context from checks skipped due to timeout of 90000ms (3)
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (1)
apps/event-worker/src/workers/compute-policy-target-release-target-selector.ts (1)
74-82: AvoidSELECT *when acquiring locks – fetch only the minimal columns neededThe locking query currently pulls all columns from both tables even though the result set is immediately discarded. This unnecessarily increases I/O and memory pressure inside the transaction.
- await tx.execute( - sql` - SELECT * from ${schema.computedPolicyTargetReleaseTarget} - INNER JOIN ${schema.releaseTarget} ON ${eq(schema.releaseTarget.id, schema.computedPolicyTargetReleaseTarget.releaseTargetId)} - WHERE ${eq(schema.computedPolicyTargetReleaseTarget.policyTargetId, policyTarget.id)} - FOR UPDATE NOWAIT - `, - ); + await tx.execute( + sql` + /* row-lock only the PKs we care about */ + SELECT ${schema.computedPolicyTargetReleaseTarget.id} + FROM ${schema.computedPolicyTargetReleaseTarget} + INNER JOIN ${schema.releaseTarget} + ON ${eq( + schema.releaseTarget.id, + schema.computedPolicyTargetReleaseTarget.releaseTargetId, + )} + WHERE ${eq( + schema.computedPolicyTargetReleaseTarget.policyTargetId, + policyTarget.id, + )} + FOR UPDATE NOWAIT + `, + );Smaller result sets shorten lock-hold time and keep the transaction lighter.
📜 Review details
Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
apps/event-worker/src/workers/compute-policy-target-release-target-selector.ts(3 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
`**/*.{ts,tsx}`: **Note on Error Handling:** Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error...
**/*.{ts,tsx}: Note on Error Handling:
Avoid strict enforcement of try/catch blocks. Code may use early returns, Promise chains (.then().catch()), or other patterns for error handling. These are acceptable as long as they maintain clarity and predictability.
apps/event-worker/src/workers/compute-policy-target-release-target-selector.ts
⏰ Context from checks skipped due to timeout of 90000ms (3)
- GitHub Check: Typecheck
- GitHub Check: Lint
- GitHub Check: build (linux/amd64)
Summary by CodeRabbit