lettuce icon indicating copy to clipboard operation
lettuce copied to clipboard

Reduce excessive off-heap memor caused by occasional large key

Open yeyinglang opened this issue 9 months ago • 1 comments

Closes #3237

  1. When the readBuffer is insufficient, a temporary large buffer will be created.
  2. Once the current command processing is completed, the temporary large buffer will be released, and the readBuffer will be restored.
  3. Even in the case of an exception, if the large object is not released during this processing, it will still be released during the next request.

Make sure that:

  • [x] You have read the contribution guidelines.
  • [x] You have created a feature request first to discuss your contribution intent. Please reference the feature request ticket number in the pull request.
  • [x] You applied code formatting rules using the mvn formatter:format target. Don’t submit any formatting related changes.
  • [x] You submit test cases (unit or integration tests) that back your changes.

yeyinglang avatar Apr 01 '25 11:04 yeyinglang

BenchMark Setup

JMH version: 1.21 VM version: JDK 1.8.0_442, OpenJDK 64-Bit Server VM, 25.442-b06 OS: Mac OS Sequoia 15.1 Arch: Apple M3 Pro VM invoker: /Library/Java/JavaVirtualMachines/temurin-8.jdk/Contents/Home/jre/bin/java Warmup: 5 iterations, 10 s each Measurement: 5 iterations, 10 s each Timeout: 2 s per iteration, Threads: 1 thread, will synchronize iterations Benchmark mode: Average time, time/op

Before

Benchmark Mode Cnt Score Error Units CommandHandlerBenchmark.measureNettyWriteAndRead avgt 5 187.513 ± 18.123 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch1 avgt 5 139.423 ± 3.800 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch10 avgt 5 1229.034 ± 126.325 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch100 avgt 5 14325.850 ± 568.049 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch1000 avgt 5 134176.816 ± 4066.024 ns/op

After

Benchmark Mode Cnt Score Error Units CommandHandlerBenchmark.measureNettyWriteAndRead avgt 5 179.508 ± 27.306 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch1 avgt 5 142.241 ± 17.666 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch10 avgt 5 1359.862 ± 59.279 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch100 avgt 5 13541.736 ± 721.837 ns/op CommandHandlerBenchmark.measureNettyWriteAndReadBatch1000 avgt 5 138272.823 ± 8509.574 ns/op

yeyinglang avatar Apr 01 '25 11:04 yeyinglang