songgaoye opened a new pull request, #3609:
URL: https://github.com/apache/brpc/pull/3609

   ### What problem does this PR solve?
   
   Issue Number: resolve
   
   Problem Summary:
   
   `RedisCommandFormatV()` and `RedisCommandNoFormat()` first assemble the
   formatted RESP payload in a `std::string`, then copy it into the destination
   `IOBuf`. This adds an avoidable full-payload copy and may cause intermediate
   string allocations for large or multi-component commands.
   
   ### What is changed and the side effects?
   
   Changed:
   
   - Use `butil::IOBufAppender` for the intermediate formatted payload.
   - Move completed `IOBuf` blocks into the destination buffer instead of 
copying
     the complete payload again.
   - Add coverage for binary payload formatting and `RedisCommandNoFormat()`.
   
   Side effects:
   
   * Performance effects:
   
     Reduces one payload-sized memory copy during Redis command formatting.
   
     A local Release microbenchmark on Apple Silicon macOS measured the 
following
     median time per operation over five runs of 1,000,000 iterations each:
   
     | Case | Before | After | Improvement |
     | --- | ---: | ---: | ---: |
     | `SET key value` | 115.3 ns | 101.8 ns | 11.7% |
     | multi-component `MSET` | 337.3 ns | 294.9 ns | 12.5% |
     | `SET` with a 4 KiB payload | 304.2 ns | 255.3 ns | 16.1% |
   
     Results are workload- and platform-dependent.
   
   * Breaking backward compatibility:
   
     None.
   
   * * *
   
   ### Check List:
   
   - [x] Add unit tests
   - [x] Run `brpc_redis_unittest --gtest_filter=RedisCommandFormatTest.*`
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to