feat(pipe): add dynamic concurrency autoscaling#119
Open
fxsml wants to merge 6 commits into
Open
Conversation
Add AutoscaleConfig to Config struct enabling automatic worker scaling based on backpressure. When all workers are busy, new workers spawn up to MaxWorkers. When workers are idle beyond ScaleDownAfter, they are stopped down to MinWorkers. Features: - AutoscaleConfig with MinWorkers, MaxWorkers, ScaleDownAfter - ScaleUpCooldown and ScaleDownCooldown to prevent thrashing - CheckInterval for scaler evaluation frequency - Backward compatible: existing Concurrency config still works Implementation: - pipe/autoscale.go: AutoscaleConfig type - pipe/internal/autoscale/: Pool with worker lifecycle management - Integrates with existing startProcessing via delegation
Add comprehensive edge case tests for autoscale pool: - Goroutine leak tests (input close, context cancel, Stop()) - Empty input handling - Context cancellation behavior - Scale-up cooldown enforcement - Multiple outputs per input Add benchmark tests comparing static concurrency vs autoscale: - Various worker counts and item counts - Direct comparison benchmarks - Burst load pattern benchmarks Results show autoscale performs better for burst workloads (~76ms vs ~146ms) by scaling up during load spikes.
- Extract startStaticProcessing() for consistent abstraction level - Make startProcessing() a simple dispatcher between static/autoscale - Add AutoscaleConfig.parse() method with defaultAutoscaleConfig - Remove duplicate Config type from internal/autoscale package - Remove ProcessFunc duplication, use generic function parameter - Rename internal autoscale.Config to PoolConfig for clarity - Update tests to use PoolConfig directly Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Mark status as Implemented - Update file structure to match actual implementation - Add Convention Alignment section documenting patterns used - Simplify to focus on what was built vs original design - Remove implementation steps (already done) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Update pipe-autoscaling.md to use PoolConfig/Workers naming convention (aligned with message package) - Add reference to future ordering extension - Create pipe-ordering.md with sequence-based reordering proposal - Update plans README with new ordering plan
- Remove nested AutoscaleConfig, unify into single PoolConfig - Workers serves dual purpose: static count or autoscale minimum - MaxWorkers > Workers enables autoscaling (implicit mode selection) - Separate Config (pipe behavior) from PoolConfig (worker config) - Update ordering plan to use new config structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
AutoscaleConfigtopipe.Configfor automatic worker scaling based on loadChanges
pipe/autoscale.go: publicAutoscaleConfigtypepipe/internal/autoscale/pool.go: pool implementation with scaling logicpipe/processing.go: integration with ProcessPipedocs/plans/pipe-autoscaling.mdandpipe-ordering.mdTest Plan
make checkpasses