优化MultiBulkReply.ToBytes中内存分配的方式(提前分配);避免使用concatstrings和slicebytetos… #211
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
提交说明
本次提交主要是优化MultiBulkReply.ToBytes()方法;通过进来减少不必要的内存分配和字符串转换/拼接操作,从而提高性能和MultiBulkReply返回值的吞吐率;经过测试,对返回大批量数据的时候(例如LRANGE),性能提升明显.测试结果如下.
基准测试(非LRANG)
测试环境
OS:Centos 7
VM:VM Workstation 17.5.0
VM配置:2C4G
测试结果
Now:当前版本
New Version:本次提交的版本
测试方法:运行以下指令3次,取平均值
总结:本次提交的性能优化,对非LRANGE的指令吞吐率有部分提升;
测试方法:运行以下指令3次,取平均值
总结:本次提交的性能优化,对LRANGE的指令吞吐率提升明显,部分超过Redis6;