-
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-18-fix_parallelize_publish_signal_awaits
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 |
eda671f to
2f81c6e
Compare
b8b2cef to
d8d4e18
Compare
879f607 to
cda5885
Compare
PR Review: fix(gas): optimize loopsSummaryThis PR introduces two optimizations to workflow loop handling in gasoline:
🔴 Critical Issue: Data Loss on CrashThe batched commit optimization introduces a durability concern. If the workflow crashes between commits (iterations 1-19, 21-39, etc.), the loop state is lost and will replay from the last committed iteration. Scenario:
This could cause:
Recommendation: Consider whether this trade-off is acceptable for your use case. If loops should be fully durable, this optimization may not be appropriate. If the loop bodies are idempotent and replay-safe, document this requirement clearly. 🟡 Potential Issues1. Error handling order in
|
PR Review: fix(gas): optimize loopsSummaryThis PR optimizes the workflow loop implementation in Gasoline by:
Code Quality & Design ✅Strengths:
Minor observations:
Potential Issues & Concerns
|
More templates
@rivetkit/cloudflare-workers
@rivetkit/db
@rivetkit/framework-base
@rivetkit/next-js
@rivetkit/react
rivetkit
@rivetkit/sql-loader
@rivetkit/engine-runner
@rivetkit/engine-runner-protocol
commit: |
cda5885 to
d6cccca
Compare
d8d4e18 to
2bb1c49
Compare
Code Review: fix(gas): optimize loopsSummaryThis PR optimizes the workflow loop implementation in gasoline by:
👍 What's Good
|
PR Review: fix(gas): optimize loopsSummaryThis PR introduces two optimizations to the workflow loop implementation in gasoline:
Code Quality ✅
Potential Issues
|

No description provided.