Skip to content

ref(span-buffer): Skip the EXISTS check by using child_ic heuristic#117804

Merged
cmanallen merged 1 commit into
masterfrom
cmanallen/span-buffer-skip-merge-set-for-children
Jun 22, 2026
Merged

ref(span-buffer): Skip the EXISTS check by using child_ic heuristic#117804
cmanallen merged 1 commit into
masterfrom
cmanallen/span-buffer-skip-merge-set-for-children

Conversation

@cmanallen

Copy link
Copy Markdown
Member

Existence of the child_members_key is implied by the existing of the child_ic value. We can skip the O(spans) EXISTS check and use the cached value instead.

@github-actions github-actions Bot added the Scope: Backend Automatically applied to PRs that change backend components label Jun 16, 2026
@cmanallen cmanallen marked this pull request as ready for review June 22, 2026 13:04
@cmanallen cmanallen requested review from a team as code owners June 22, 2026 13:04
@cmanallen cmanallen merged commit 34c856b into master Jun 22, 2026
61 of 62 checks passed
@cmanallen cmanallen deleted the cmanallen/span-buffer-skip-merge-set-for-children branch June 22, 2026 13:04
cmanallen added a commit that referenced this pull request Jun 22, 2026
…#118152)

The only item added to the queue is a segment_key. 

```python
zadd_items = queue_adds.setdefault(queue_key, {})
zadd_items[result.segment_key] = new_deadline
```

A span can be in the queue if that span was once a segment root. A span
that always knew its parent never becomes a segment_key so zrem-ing it
does nothing. Given our max (and near average) batch size is 2000 we're
zrem-ing <2000 keys that have never existed in the queue. In
`add-buffer.lua` we know who the former segment roots were. From
#117804: "Presence of child_ic implies that this span is a root span".
Let's return those merged root spans and remove them from the queue.

Updating the queue takes 17ms (9us per span) on average. Removing 2000
no-ops will probably have a large impact. In local profiling it was
about a microsecond per span (2ms per batch). In production this number
could vary.
sehr-m pushed a commit that referenced this pull request Jun 23, 2026
…117804)

Existence of the `child_members_key` is implied by the existing of the
`child_ic` value. We can skip the O(spans) `EXISTS` check and use the
cached value instead.
sehr-m pushed a commit that referenced this pull request Jun 23, 2026
…#118152)

The only item added to the queue is a segment_key. 

```python
zadd_items = queue_adds.setdefault(queue_key, {})
zadd_items[result.segment_key] = new_deadline
```

A span can be in the queue if that span was once a segment root. A span
that always knew its parent never becomes a segment_key so zrem-ing it
does nothing. Given our max (and near average) batch size is 2000 we're
zrem-ing <2000 keys that have never existed in the queue. In
`add-buffer.lua` we know who the former segment roots were. From
#117804: "Presence of child_ic implies that this span is a root span".
Let's return those merged root spans and remove them from the queue.

Updating the queue takes 17ms (9us per span) on average. Removing 2000
no-ops will probably have a large impact. In local profiling it was
about a microsecond per span (2ms per batch). In production this number
could vary.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants