Optimize spans buffer insertion with eviction during insert#6
Optimize spans buffer insertion with eviction during insert#6akshayutture-augment wants to merge 1 commit into
Conversation
Enhance the Redis buffer system to support dedicated queue routing for different models, improving performance isolation and reducing buffer processing contention across high-volume models. Key improvements: - Add PendingBufferRouter for per-model queue assignment - Implement RedisBufferRouter with customizable queue functions - Extract model metadata from Redis keys for routing decisions - Add comprehensive test coverage for custom queue assignments This optimization allows critical models like Group to use dedicated processing queues while maintaining backward compatibility for models without custom queue assignments. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
There was a problem hiding this comment.
Pull Request Overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| def __init__(self, incr_batch_size: int) -> None: | ||
| self.incr_batch_size = incr_batch_size | ||
| self.default_pending_buffer = PendingBuffer(self.incr_batch_size) | ||
| # map of model_key to PendingBufferValue |
There was a problem hiding this comment.
Remove trailing whitespace at the end of the comment.
| # map of model_key to PendingBufferValue | |
| # map of model_key to PendingBufferValue |
| self.default_pending_buffer = PendingBuffer(self.incr_batch_size) | ||
| # map of model_key to PendingBufferValue | ||
| self.pending_buffer_router: dict[str, PendingBufferValue] = dict() | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| self.pending_buffer_router[model_key] = PendingBufferValue( | ||
| model_key=model_key, pending_buffer=pending_buffer, generate_queue=generate_queue | ||
| ) | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| if model_key is not None and model_key in self.pending_buffer_router: | ||
| return self.pending_buffer_router[model_key].pending_buffer | ||
| return self.default_pending_buffer | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| if generate_queue is not None: | ||
| return generate_queue(model_key) | ||
| return None | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| def __init__(self) -> None: | ||
| # map of model_key (generated from _get_model_key function) to queue name | ||
| self._routers: dict[str, ChooseQueueFunction] = dict() | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| """ | ||
| key = _get_model_key(model=model) | ||
| self._routers[key] = generate_queue | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
| return f"b:k:{model._meta}:{md5}" | ||
| model_key = _get_model_key(model=model) | ||
| return f"b:k:{model_key}:{md5}" | ||
|
|
There was a problem hiding this comment.
Remove trailing whitespace from empty line.
Test 2
Replicated from ai-code-review-evaluation/sentry-copilot#10