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

Use HashedWheelTimer for command timeout scheduling to reduce thread context switches and improve performance #2774

Closed
wants to merge 1 commit into from

Conversation

yangty89
Copy link
Contributor

@yangty89 yangty89 commented Mar 6, 2024

Use HashedWheelTimer for command timeout scheduling to reduce thread context switches and improve performance under heavy load, refer feature request #2773.

Benchmarks

Environment: MacBook Pro with 2 GHz quad-core Intel Core i5 and 16 GB memory, JDK 11 (Amazon Corretto version 11.0.21)

Benchmark of RedisClientBenchmark#syncSet:

    @Threads(numThread)
    @Fork(1)
    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    @Warmup(iterations = 1, time = 30, timeUnit = TimeUnit.SECONDS)
    @Measurement(iterations = 2, time = 30, timeUnit = TimeUnit.SECONDS)
    public void syncSet() {
        connection.sync().set(KEY, KEY);
    }
  • 200 threads (@Threads(200)), executor group with 8 worker threads: 66726 ops
  • 200 threads, executor group with 2 worker threads: 75705 ops
  • 200 threads, timer: 100396 ops (performance increase of 33% to 50%)
  • 100 threads (@Threads(100)), executor group with 8 worker threads: 72308 ops
  • 100 threads, executor group with 2 worker threads: 92572 ops
  • 100 threads, timer: 119837 ops (performance increase of 29% to 66%)
  • 50 threads (@Threads(50)), executor group with 8 worker threads: 90376 ops
  • 50 threads, executor group with 2 worker threads: 99735 ops
  • 50 threads, timer: 125491 ops (performance increase of 26% to 39%)

Benchmark of RedisClientBenchmark#syncList:

    @Threads(100)
    @Fork(1)
    @Benchmark
    @BenchmarkMode(Mode.Throughput)
    @Warmup(iterations = 1, time = 30, timeUnit = TimeUnit.SECONDS)
    @Measurement(iterations = 2, time = 30, timeUnit = TimeUnit.SECONDS)
    public void syncList() {
        connection.async().del(FOO);
        connection.sync().lpush(FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO, FOO,
                FOO);
        connection.sync().lrange(FOO, 0, -1);
    }
  • executor group with 8 worker threads: 26025 ops
  • executor group with 2 worker threads: 30407 ops
  • timer: 38308 ops (performance increase of 26% to 47%)

  • You have read the contribution guidelines.
  • You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • You use the code formatters provided here and have them applied to your changes. Don’t submit any formatting related changes.
  • You submit test cases (unit or integration tests) that back your changes.

@mp911de mp911de added the type: feature A new feature label Mar 7, 2024
@mp911de mp911de self-assigned this Mar 7, 2024
@mp911de mp911de added this to the 6.3.2.RELEASE milestone Mar 7, 2024
mp911de pushed a commit that referenced this pull request Mar 7, 2024
…d context switches and improve performance #2773

Original pull request: #2774
mp911de added a commit that referenced this pull request Mar 7, 2024
Reformat code. Resolve warnings.

Original pull request: #2774
mp911de pushed a commit that referenced this pull request Mar 7, 2024
…d context switches and improve performance #2773

Original pull request: #2774
mp911de added a commit that referenced this pull request Mar 7, 2024
Reformat code. Resolve warnings.

Original pull request: #2774
@mp911de
Copy link
Collaborator

mp911de commented Mar 7, 2024

Thank you for your contribution. That's merged, polished, and backported now.

@mp911de mp911de closed this Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature A new feature
Projects
None yet
2 participants