Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimize zunion[store] command by avoiding the duplicate copy of dict #13155

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

lyq2333
Copy link
Contributor

@lyq2333 lyq2333 commented Mar 19, 2024

In the past zunion and zunionstore command, we first constructed a accumulator dict and then converted it into the final sorted set. But we can use the dict in dstobj directly to avoid the cost of constructing a new dict during converting to improve performance.

In this PR, I removed the accumulator dict and replace it with the dict in dstobj.

I made a test on zunion and zunionstore command. I first add two zsets each with 100 unique elements. Then I call zunion or zunionstore on these zsets. The result shows the performance can improve about 18%.

zunion

unstable

Summary:
  throughput summary: 6488.24 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        7.253     0.976     7.207     8.087     8.335    11.039

This PR

Summary:
  throughput summary: 7651.99 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        6.083     0.976     6.031     6.935     7.191    10.991

zunionstore

unstable

Summary:
  throughput summary: 7036.55 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        7.015     0.992     7.943     8.543     8.767    17.887

This PR

Summary:
  throughput summary: 8353.52 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        5.896     0.968     6.663     7.263     7.559    16.111

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants