-
Notifications
You must be signed in to change notification settings - Fork 133
fix(gas): optimize loops #3475
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
base: 11-13-chore_rename_retry_-_hibernate_in_runner_protocol
Are you sure you want to change the base?
fix(gas): optimize loops #3475
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. 4 Skipped Deployments
|
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
How to use the Graphite Merge QueueAdd the label merge-queue to this PR to add it to the merge queue. You must have a Graphite account in order to use the merge queue. Sign up using this link. An organization admin has enabled the Graphite Merge Queue in this repository. Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue. This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR Review: fix(gas): optimize loopsSummaryThis PR optimizes loop performance in the workflow engine by:
Code Quality & Best PracticesStrengths:
Concerns:
Potential BugsCritical Issue: The optimization introduces a correctness bug. Looking at line 994: if iteration % LOOP_ITERS_PER_COMMIT == 0 {
self.db.upsert_workflow_loop_event(...)
}The modulo check means:
But the loop event was already created at iteration 0 (lines 892-904), so iteration 20 would be the first update. However, if the loop breaks at iteration 15, the final state IS committed (lines 1021-1032), so that case is handled. The real issue: If a workflow crashes/restarts between commits (e.g., at iteration 15), it will replay from iteration 0, not iteration 15. This changes the recovery semantics. Performance ConsiderationsPositive:
Concerns:
Security ConcernsNo security issues identified. The changes are confined to internal workflow state management. Test CoverageMissing tests for the optimization:
Recommended tests: // Test that loop state is persisted every LOOP_ITERS_PER_COMMIT iterations
#[test]
async fn test_loop_commit_batching() {
// Run a loop for 50 iterations
// Kill and restart the workflow at iteration 35
// Verify it resumes from iteration 20 (last commit), not iteration 0
}
// Test that final state is always committed on Loop::Break
#[test]
async fn test_loop_final_state_commit() {
// Run loop that breaks at arbitrary iteration (e.g., 15)
// Verify final state is persisted correctly
}Recommendations
Questions for Author
Overall Assessment: The optimization is well-intentioned but potentially introduces a subtle correctness issue around crash recovery. I'd recommend either:
Happy to discuss further! 🤖 Generated with Claude Code |

No description provided.