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
This commit introduces the foundational layer for the Flow Registry, which will act as the stateful control plane for managing queues and policies. It defines the `ManagedQueue` decorator, refines the system's core service contracts, and simplifies the queue plugin interface.
The key changes are:
1. **`ports` -> `contracts` Rename**: The `ports` package is renamed to `contracts` to more accurately reflect the "Ports and Adapters" architectural pattern and avoid confusion with network ports.
2. **`ManagedQueue` Introduction**: A new `registry.managedQueue` component is introduced. It acts as a stateful decorator around a `framework.SafeQueue`, adding critical registry-level functionality:
- **Atomic Statistics**: It maintains its own atomic `len` and `byteSize` counters.
- **State Reconciliation**: It uses a callback to propagate statistical deltas to its parent (the future `RegistryShard`), ensuring aggregated stats remain consistent without locks.
3. **`SafeQueue` Interface Simplification**: The `framework.SafeQueue` interface is simplified. The `Add` and `Remove` methods no longer return the new queue state, as this responsibility is now correctly handled by the `ManagedQueue` decorator. This makes the `SafeQueue` contract cleaner and more focused on its core queuing logic.
The benchmark results highlight the trade-offs between the different queue implementations based on their underlying
95
95
data structures:
96
96
97
97
-**`ListQueue`**: As a linked list, it excels in scenarios involving frequent additions or removals from either end of
98
-
the queue (`AddPeekRemove`, `AddPeekTailRemove`), which are O(1) operations. Its performance is less competitive in high-contention and bulk scenarios, which reflects the necessary per-item memory allocation and pointer manipulation
99
-
overhead.
98
+
the queue (`AddPeekRemove`, `AddPeekTailRemove`), which are O(1) operations. The `HighContention` benchmark shows that
99
+
its simple, low-overhead operations are also extremely performant for consumer throughput even under heavy concurrent
100
+
load.
100
101
-**`MaxMinHeap`**: As a slice-based heap, it has a lower allocation overhead per operation, making it efficient for
101
102
high-throughput `AddRemove` cycles. Peeking and removing items involves maintaining the heap property, which has an
102
103
O(log n) cost, making individual peek operations slower than `ListQueue`.
0 commit comments