feat(spans): Optimize spans buffer insertion with eviction during insert#3
feat(spans): Optimize spans buffer insertion with eviction during insert#3zaibkhan wants to merge 3 commits into
Conversation
A proof of concept that limits the number of spans per segment during insertion. Internally, this uses a sorted set scored by the spans' end timestamps and evicts the oldest spans. This ensures that spans higher up in the hierarchy and more recent spans are prioritized during the eviction.
…loyments This change introduces optimized cursor-based pagination for audit log endpoints to improve performance in enterprise environments with large audit datasets. Key improvements: - Added OptimizedCursorPaginator with advanced boundary handling - Enhanced cursor offset support for efficient bi-directional navigation - Performance optimizations for administrative audit log access patterns - Backward compatible with existing DateTimePaginator implementation The enhanced paginator enables more efficient traversal of large audit datasets while maintaining security boundaries and access controls. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
Codoki PR ReviewSummary: Fix datetime key handling, prevent negative slicing, add guard Issues (Critical & High only)
Key Feedback (click to expand)
Confidence: 3/5 — Needs work before merge (2 high · status: Requires changes) React with 👍 or 👎 if you found this review useful. |
| queryset = self.build_queryset(cursor_value, cursor.is_prev) | ||
|
|
||
| if max_hits is None: | ||
| max_hits = MAX_HITS_LIMIT |
There was a problem hiding this comment.
| max_hits = MAX_HITS_LIMIT | |
| return int(value.replace(tzinfo=timezone.utc).timestamp()) if isinstance(value, datetime) else int(math.floor(value) if self._is_asc(for_prev) else math.ceil(value)) |
| if results and self.get_item_key(results[0], for_prev=True) == cursor.value: | ||
| results = results[1:] | ||
| elif len(results) == offset + limit + extra: | ||
| results = results[:-1] |
There was a problem hiding this comment.
| results = results[:-1] | |
| start_offset = max(0, cursor.offset) |
This change introduces span buffer eviction during insert operations to reduce memory growth under high-volume tracing workloads.
Key improvements:
Benchmark reference:
Replicated from ai-code-review-evaluation/sentry-greptile PR #2