Skip to content

Optimize the performance of sdscatrepr in printable characters#11725

Merged
oranagra merged 1 commit into
redis:unstablefrom
judeng:sdscatrepr
Jan 22, 2023
Merged

Optimize the performance of sdscatrepr in printable characters#11725
oranagra merged 1 commit into
redis:unstablefrom
judeng:sdscatrepr

Conversation

@judeng

@judeng judeng commented Jan 17, 2023

Copy link
Copy Markdown
Contributor

sdscatrepr is not the hot path in redis, but it helpful for some project with sds.c, so it is still worth optimizing its performance

@zuiderkwast zuiderkwast left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@filipecosta90 filipecosta90 added the action:run-benchmark Triggers the benchmark suite for this Pull Request label Jan 17, 2023
@filipecosta90

Copy link
Copy Markdown
Contributor

Automated performance analysis summary

This comment was automatically generated given there is performance data available.

Using platform named: amd64-aws-m6i.8xlarge to do the comparison.

In summary:

  • Detected a total of 11 stable tests between versions.

Comparison between unstable and judeng:sdscatrepr.

Time Period from a month ago. (environment used: oss-standalone)

Test Case Baseline unstable (median obs. +- std.dev) Comparison judeng:sdscatrepr (median obs. +- std.dev) % change (higher-better) Note
memtier_benchmark-10Mkeys-load-hash-5-fields-with-1000B-values-pipeline-10 181081 +- 1.1% (3 datapoints) 176754 +- nan% (1 datapoints) -2.4% -- no change --
memtier_benchmark-1Mkeys-10B-expire-use-case 225330 +- 0.3% (3 datapoints) 226617 +- nan% (1 datapoints) 0.6% -- no change --
memtier_benchmark-1Mkeys-load-hash-5-fields-with-1000B-values 102242 +- 2.1% (3 datapoints) 101398 +- nan% (1 datapoints) -0.8% -- no change --
memtier_benchmark-1Mkeys-load-hash-5-fields-with-1000B-values-pipeline-10 185605 +- 0.5% (3 datapoints) 180700 +- nan% (1 datapoints) -2.6% -- no change --
memtier_benchmark-1Mkeys-load-string-with-100B-values-pipeline-10 655467 +- 1.1% (3 datapoints) 651774 +- nan% (1 datapoints) -0.6% -- no change --
memtier_benchmark-1Mkeys-string-get-100B-pipeline-10 1288740 +- 1.1% (3 datapoints) 1265931 +- nan% (1 datapoints) -1.8% -- no change --
memtier_benchmark-1key-list-10-elements-lrange-all-elements 153095 +- 1.4% (3 datapoints) 149273 +- nan% (1 datapoints) -2.5% -- no change --
memtier_benchmark-1key-list-1K-elements-lrange-all-elements 27172 +- 0.5% (3 datapoints) 27118 +- nan% (1 datapoints) -0.2% -- no change --
memtier_benchmark-1key-zset-100-elements-zrange-all-elements 28544 +- 0.4% (3 datapoints) 28581 +- nan% (1 datapoints) 0.1% -- no change --
memtier_benchmark-1key-zset-1M-elements-zrevrange-5-elements 151392 +- 7.2% (3 datapoints) 148892 +- nan% (1 datapoints) -1.7% waterline=7.2%. -- no change --
memtier_benchmark-2keys-set-10-100-elements-sdiff 25842 +- 0.1% (3 datapoints) 26192 +- nan% (1 datapoints) 1.4% -- no change --

@filipecosta90

Copy link
Copy Markdown
Contributor

@judeng / @zuiderkwast / @artikell looking at the performance data there is no significant change on the benchmarks detected ( I'm extending the runs to include all 60 benchmarks ).
Don't you want to think of benchmarks that would detect this improvement ( and in consequence detect regressions in the future about any change ) before merging?

@zuiderkwast

Copy link
Copy Markdown
Contributor

@filipecosta90 As @judeng wrote in the top comment (quoted) this is not in the hot path of redis, so it's unlikely to affect performance.

sdscatrepr is not the hot path in redis, but it helpful for some project with sds.c, so it is still worth optimizing its performance

Maybe it affects performance of redis-cli or some external tools which copy the sds library such as hiredis... @judeng anything in particular you're using this for?

Anyway, I think this change is also a simplification of the code, so it can be worth merging anyway.

@artikell

Copy link
Copy Markdown
Contributor

sdscarepr does not seem to be a hot path. I found that when there is a monitor, the replicationFeedMonitors will use the sdscarepr method. Maybe we can test it?

@artikell

Copy link
Copy Markdown
Contributor

i use redis-benchmark --threads 2 -P 10 -r 100 -n 10000000 getset __rand_int__ __rand_int__ to test. The test results are as follows

unstable(no monitor)

Summary:
  throughput summary: 264669.28 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        1.663     0.304     1.623     2.487     3.383    45.855

unstable(1monitor)

Summary:
  throughput summary: 78633.66 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        5.917     0.312     4.815    11.711    31.775   171.391

judeng:sdscatrepr(no monitor)

Summary:
  throughput summary: 255761.02 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        1.710     0.320     1.631     2.727     3.759    36.415

judeng:sdscatrepr(1 monitor)

Summary:
  throughput summary: 106142.47 requests per second
  latency summary (msec):
          avg       min       p50       p95       p99       max
        4.347     0.328     3.695     7.783    18.031   107.711

roughly 34% improvement。

@judeng

judeng commented Jan 19, 2023

Copy link
Copy Markdown
Contributor Author

@artikell Thanks for your test, the optimization of monitor was a surprise to me :-)

@judeng

judeng commented Jan 19, 2023

Copy link
Copy Markdown
Contributor Author

@filipecosta90 Thank you for the benchmark results you shared, I did not perform benchmark tests on redis, but only pressure tested the function in my project, which showed a great performance improvement.
maybe we can add some independent performance test cases in sdsTest to cover the basic functions, WDYT?

@judeng

judeng commented Jan 19, 2023

Copy link
Copy Markdown
Contributor Author

@zuiderkwast I am trying to make a tool based sds to audit redis's requests

@oranagra oranagra left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM, seems like a straight forward improvement and doesn't add any complexity.
even if it's not measurable in most workflows, i think we should take it.

@oranagra oranagra merged commit afd9e3e into redis:unstable Jan 22, 2023
@judeng judeng deleted the sdscatrepr branch January 31, 2023 05:48
enjoy-binbin pushed a commit to enjoy-binbin/redis that referenced this pull request Jul 31, 2023
…#11725)

sdscatrepr is not the hot path in redis, but it's still useful to have make it less wasteful.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action:run-benchmark Triggers the benchmark suite for this Pull Request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants