feat(runtime): add autoscaler for automatic worker thread scaling#29
Merged
feat(runtime): add autoscaler for automatic worker thread scaling#29
Conversation
Implement two new synchronization primitives: - spinlock: TTAS (Test-and-Test-and-Set) algorithm with CPU pause instructions for efficient spinning. Includes spinlock_guard with RAII, move semantics, and manual unlock support. - condition_variable: Coroutine-aware condition variable that suspends instead of blocking. Supports three usage modes: - With mutex (double co_await pattern for async re-lock) - With spinlock/lockable (single co_await, sync re-lock) - Unlocked mode for single-worker-thread scenarios Provides notify_one() and notify_all() via scheduler handle rescheduling. Includes comprehensive tests (12 test cases) covering basic operations, coroutine integration, RAII guards, move semantics, producer-consumer patterns, and notify_one/notify_all semantics. All tests pass under ASAN and TSAN with no warnings. Updates wiki documentation (API-Reference.md, Core-Concepts.md) with full API signatures, usage examples, and design guidance.
039c379 to
137bd3d
Compare
Add autoscaler component that automatically adjusts worker thread count based on load. Includes: - autoscaler_config: Configurable thresholds for scaling decisions - autoscaler_triggers: Template-based trigger types (on_overload, on_idle, on_block) - autoscaler_actions: Action types and combinators (scale_up, scale_down, log, null) - autoscaler_impl: Main autoscaler with default trigger behavior Features: - Automatic scale-up when pending tasks exceed overload threshold - Automatic scale-down when queue is idle for configured delay - Block detection for workers stuck in user code - Template-based trigger-action system for extensibility - Default behavior works without custom triggers Add worker metrics tracking (last_task_time, is_idle) to support autoscaler block detection. Update examples, documentation, and tests.
8a47d10 to
327e64e
Compare
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
Test Plan