Skip to content

ref(spans-buffer): Clean up ZSET code#107863

Merged
evanh merged 7 commits intomasterfrom
tony/cleanup-spans-buffer-zset
Feb 11, 2026
Merged

ref(spans-buffer): Clean up ZSET code#107863
evanh merged 7 commits intomasterfrom
tony/cleanup-spans-buffer-zset

Conversation

@lvthanh03
Copy link
Member

Cleans up old ZSET code to finish off spans buffer migration to unsorted sets.

@lvthanh03 lvthanh03 requested review from a team as code owners February 9, 2026 19:12
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 9, 2026
Copy link
Member

@evanh evanh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, pending the rollout to ST.

Copy link
Contributor

@fpacifici fpacifici left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please fix the way the options are cleaned up

Comment on lines -3170 to -3186
# ZSET to SET migration options.
register(
"spans.buffer.write-to-zset",
default=False,
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"spans.buffer.write-to-set",
default=True,
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)
register(
"spans.buffer.read-from-set",
default=True,
flags=FLAG_PRIORITIZE_DISK | FLAG_AUTOMATOR_MODIFIABLE,
)

Copy link
Contributor

@fpacifici fpacifici Feb 10, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You cannot remove options this way.
You have to unset them first from option automator.
Which means:

  1. remove the usage of the option in code, but not the option registration. In alternative you can expedite the process by changing the default to the behavior you want.
  2. remove the option from option automator
  3. only then you can remove the option from here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you apply the changes to the add-buffer.lua manually or did you copy over the content of add-buffer-set.lua ?

Copy link
Member Author

@lvthanh03 lvthanh03 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied over the content of add-buffer-set.lua with git mv but I also made changes to the metric names (remove the set_ prefix) as well as documentation changes.

Comment on lines -152 to -185
def compare_metrics(
zset_metrics: list[EvalshaData],
set_metrics: list[EvalshaData],
) -> None:
"""
Reports the difference (SET - ZSET) between metrics.

SET metrics are expected to have a "set_" prefix (e.g., "set_redirect_depth").
Special cases are handled via ZSET_TO_SET_KEY_MAPPING.
"""
differences: dict[str, tuple[float, float, float, float]] = {}

for zset_evalsha, set_evalsha in zip(zset_metrics, set_metrics):
set_dict: dict[str, float] = {
raw_key.decode("utf-8"): value for raw_key, value in set_evalsha
}

for raw_key, zset_value in zset_evalsha:
zset_key = raw_key.decode("utf-8")
set_key = ZSET_TO_SET_KEY_MAPPING.get(zset_key, f"set_{zset_key}")

if set_key not in set_dict:
continue

diff = set_dict[set_key] - zset_value

if zset_key not in differences:
differences[zset_key] = (diff, diff, diff, 1.0)
else:
differences[zset_key] = (
min(differences[zset_key][0], diff),
max(differences[zset_key][1], diff),
differences[zset_key][2] + diff,
differences[zset_key][3] + 1.0,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think @evanh may still need this for #107809

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK to remove it, I will update my code accordingly.

Copy link
Member Author

@lvthanh03 lvthanh03 Feb 11, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we want to do EVALSHA comparisons in the future, we can keep this function. I can modify this into something more generic (i.e. comparing between metrics_A: list[EvalshaData] and metrics_B: list[EvalshaData]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure let's do that. Thanks!

Copy link
Contributor

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Base automatically changed from tony/disable-write-to-zset to master February 11, 2026 14:16
@evanh evanh merged commit 2abb8ba into master Feb 11, 2026
69 of 70 checks passed
@evanh evanh deleted the tony/cleanup-spans-buffer-zset branch February 11, 2026 17:16
jaydgoss pushed a commit that referenced this pull request Feb 12, 2026
Cleans up old ZSET code to finish off spans buffer migration to unsorted
sets.
@github-actions github-actions bot locked and limited conversation to collaborators Feb 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

claude-code-assisted Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants