-
Notifications
You must be signed in to change notification settings - Fork 134
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.
3 Skipped Deployments
|
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 |
bbe84e7 to
e83ac9b
Compare
e5b2d7f to
eda671f
Compare
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! 🤖 Review generated with Claude Code |

No description provided.