feat(uptime): Add ability to use queues to manage parallelism#9
feat(uptime): Add ability to use queues to manage parallelism#9zaibkhan wants to merge 1 commit into
Conversation
One potential problem we have with batch processing is that any one slow item will clog up the whole batch. This pr implements a queueing method instead, where we keep N queues that each have their own workers. There's still a chance of individual items backlogging a queue, but we can try increased concurrency here to reduce the chances of that happening <!-- Describe your PR here. -->
Codoki PR ReviewSummary: Fix queue worker shutdown, prevent hangs Issues (Critical & High only)
Showing top 1 issues. Critical: 0, High: 1. See inline suggestions for more. Key Feedback (click to expand)
Confidence: 3/5 — Needs work before merge (1 high · status: Requires changes) Sequence DiagramsequenceDiagram
participant Factory
participant Strategy
participant QueuePool
participant Worker
Factory->>Factory: create_thread_queue_parallel_worker(commit)
Factory-->>Strategy: SimpleQueueProcessingStrategy(decoder, grouping_fn, commit_fn)
Strategy->>QueuePool: submit(group_key, WorkItem)
QueuePool->>Worker: work_queue.put(WorkItem)
Worker->>Worker: result_processor(identifier, work_item.result)
Strategy->>Strategy: _commit_loop()
Strategy-->>Factory: commit_offsets({partition: offset+1})
React with 👍 or 👎 if you found this review useful. |
| """Process items from the queue in order.""" | ||
| while not self.shutdown: | ||
| try: | ||
| work_item = self.work_queue.get() |
There was a problem hiding this comment.
| work_item = self.work_queue.get() | |
| ```suggestion | |
| try: | |
| work_item = self.work_queue.get(timeout=0.5) | |
| if work_item is None: | |
| break | |
| except queue.Empty: | |
| continue |
|
|
||
| for q in self.queues: | ||
| try: | ||
| q.shutdown(immediate=False) |
There was a problem hiding this comment.
🔷 Medium: queue.Queue does not expose shutdown(); this raises AttributeError and logs an exception each shutdown. With the timeout-based get (or sentinel) in the worker, simply wake workers using a sentinel instead of calling a non-existent API.
| q.shutdown(immediate=False) | |
| ```suggestion | |
| q.put_nowait(None) |
Mirrors ai-code-review-evaluation#9 for like-for-like benchmarking.
kafka-consumer-parallel-beforekafka-consumer-parallel-afterOriginal PR excerpt: