You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor(Echo/Scheduler): decouple queue from scheduler and optimize work-stealing
- Restructured `StealingQueue` and `Scheduler` modules to separate generic work-stealing logic from application-specific task handling, aligning with Land's architecture principle of decoupling components.
- Implemented a more efficient work-stealing algorithm using random peer iteration to reduce contention and improve task distribution efficiency.
- Updated architectural documentation in README and Deep Dive to reflect the decoupled design and priority-aware scheduling crucial for Mountain's `ActionEffect` execution.
- Revised code examples and API documentation to match the current `SchedulerBuilder` usage, ensuring consistency across the codebase.
This refactoring enhances the scheduler's performance and maintainability, directly supporting Mountain's need for reliable and efficient execution of declarative `ActionEffect` workflows in the Land editor backend.
|**Performance**| Use lock-free data structures (`crossbeam-deque`) and a work-stealing algorithm to achieve maximum throughput and low-latency task execution. |`Queue::StealingQueue`, `Scheduler::Worker`|
65
-
|**Structured Concurrency**| Manage all asynchronous operations within a supervised pool of workers, providing graceful startup and shutdown, unlike fire-and-forget `tokio::spawn`. |`Scheduler::Scheduler`, `Scheduler::SchedulerBuilder`|
66
-
|**Decoupling**| Separate the _submission_ of a task from its _execution_. The application submits work, and the `Scheduler` handles how, when, and where it runs.|`Scheduler::Scheduler::Submit`, `Task::Task::Task`|
67
-
|**Resilience**| The scheduler's design is inherently resilient, as the failure of one task (if it panics) does not bring down the entire worker pool. |`Scheduler::Worker::Run` (execution loop)|
68
-
|**Composability**| Provide a simple, generic `Submit` API that accepts any `Future<Output = ()>`, making it easy to integrate with any asynchronous Rust code. |`Task::Task::Task`, `Scheduler::Scheduler::Submit`|
|**Performance**| Use lock-free data structures (`crossbeam-deque`) and a high-performance work-stealing algorithm to achieve maximum throughput and low-latency task execution. |`Queue::StealingQueue`, `Scheduler::Worker`|
64
+
|**Structured Concurrency**| Manage all asynchronous operations within a supervised pool of workers, providing graceful startup and shutdown, unlike fire-and-forget `tokio::spawn`. |`Scheduler::Scheduler`, `Scheduler::SchedulerBuilder`|
65
+
|**Decoupling**| Separate the generic **Queueing Logic**from the application-specific **Scheduler Implementation**. The scheduler uses the queue to run its tasks. |`Queue::StealingQueue<T>`, `Scheduler::Scheduler`, `Task::Task::Task`|
66
+
|**Resilience**| The scheduler's design is inherently resilient; the failure of one task (if it panics) is contained within its `tokio` task and does not crash the worker pool. |`Scheduler::Worker::Run`|
67
+
|**Composability**| Provide a simple`Submit` API that accepts any `Future<Output = ()>`, making it easy to integrate with any asynchronous Rust code. |`Task::Task::Task`, `Scheduler::Scheduler::Submit`|
69
68
70
69
---
71
70
@@ -120,14 +119,15 @@ graph LR
120
119
121
120
## Project Structure Overview 🗺️
122
121
123
-
The `Echo` repository is organized into a few core modules:
122
+
The `Echo` repository is organized into a few core modules with a clear
123
+
separation of concerns:
124
124
125
125
```
126
126
Echo/
127
127
└── Source/
128
128
├── Library.rs # Crate root, declares all modules.
129
-
├── Scheduler/ # The main public API: Scheduler and Builder.
130
-
├── Queue/ # The generic, high-performance work-stealing queue.
129
+
├── Scheduler/ # The main public API: Scheduler and Builder. Consumes the Queue.
130
+
├── Queue/ # The generic, high-performance work-stealing queue library.
131
131
└── Task/ # The application-specific definition of a Task and its Priority.
132
132
```
133
133
@@ -162,7 +162,8 @@ used throughout the application, often via a shared context or runtime.
0 commit comments