Optimize sdscatrepr by batch processing printable characters#1342
Conversation
Signed-off-by: Ray Cao <zisong.cw@alibaba.com>
|
I wonder if we should do something like #1230, which removes all the reallocation and just does a single initial allocation. Checking through the code, this doesn't seem to be anywhere on the hot path though, so that is probably over optimizing. |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## unstable #1342 +/- ##
============================================
+ Coverage 70.77% 70.79% +0.01%
============================================
Files 116 116
Lines 63280 63285 +5
============================================
+ Hits 44787 44802 +15
+ Misses 18493 18483 -10
|
|
As @artikell said in #11725, If there is a monitor, unstable (no monitor)unstable (1 monitor)PR (no monitor)PR (1 monitor)
|
@madolson |
I agree with optimizing the code, I was wondering we should spend more effort to optimize is than just what you are proposing in this PR.
Yeah, I was suggesting that we could do two passes. Two passes seems like it would be slower, but the work I did with sdscat showed that it was still much faster both because sdscat* functions are slow and because if we have to realloc that is also really slow. If you aren't interesting in trying any alternatives, I think this is worth merging as is though. (I'll take a look at the actual code shortly) |
|
Currently, in And in my understanding, the use cases for |
I'm not as concerned about extra memory usage. I was more interested if we could improve the performance if we avoided sds functions, which tend to be a bit slow compared to direct character manipulation. I'm fine with the PR as is though. |
…io#1342) Optimize sdscatrepr by reducing realloc calls, furthermore, we can reduce memcpy calls by batch processing of consecutive printable characters. Signed-off-by: Ray Cao <zisong.cw@alibaba.com> Co-authored-by: Ray Cao <zisong.cw@alibaba.com> Signed-off-by: vudiep411 <vdiep@amazon.com>
…io#1342) Optimize sdscatrepr by reducing realloc calls, furthermore, we can reduce memcpy calls by batch processing of consecutive printable characters. Signed-off-by: Ray Cao <zisong.cw@alibaba.com> Co-authored-by: Ray Cao <zisong.cw@alibaba.com> Signed-off-by: vudiep411 <vdiep@amazon.com>
…io#1342) Optimize sdscatrepr by reducing realloc calls, furthermore, we can reduce memcpy calls by batch processing of consecutive printable characters. Signed-off-by: Ray Cao <zisong.cw@alibaba.com> Co-authored-by: Ray Cao <zisong.cw@alibaba.com> Signed-off-by: vudiep411 <vdiep@amazon.com>
…2036) Fixes valkey-io#2035, a bug introduced in valkey-io#1342 --------- Signed-off-by: Fusl <fusl@meo.ws> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
…2036) Fixes valkey-io#2035, a bug introduced in valkey-io#1342 --------- Signed-off-by: Fusl <fusl@meo.ws> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com>
…2036) Fixes valkey-io#2035, a bug introduced in valkey-io#1342 --------- Signed-off-by: Fusl <fusl@meo.ws> Signed-off-by: Madelyn Olson <madelyneolson@gmail.com> Co-authored-by: Madelyn Olson <madelyneolson@gmail.com> Signed-off-by: Harkrishn Patro <harkrisp@amazon.com>
#11725 optimize sdscatrepr by reducing realloc calls, furthermore, we can reduce memcpy calls by batch processing of consecutive printable characters.