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

   ### What problem does this PR solve?
   
   Issue Number:
   
   Problem Summary:
   
   ```
    thread_num=1 log_type=sync log_size=100 count=462130 duration=2s qps=231065 
average_time=4349.05us
    thread_num=8 log_type=sync log_size=100 count=271989 duration=2s qps=135994 
average_time=59007.1us
    thread_num=1 log_type=async log_size=100 count=1449393 duration=2s 
qps=724696 average_time=1383.17us
    thread_num=8 log_type=async log_size=100 count=952119 duration=2s 
qps=476060 average_time=17001.6us
   ```
   
   目前异步日志(完全由异步线程落盘日志)的性能仅仅是同步日志的3倍左右,没达到每秒百万的级别。
   
   通过cpu profiler分析发现,瓶颈在`PrintLogPrefix`,特别是`localtime_r`或者`localtime_s`(有锁)。
   
   ### What is changed and the side effects?
   
   Changed:
   
   将`PrintLogPrefix`逻辑后移到异步线程运行,加快`LOG(xxx)`的速度。
   
   优化后,异步日志性能得到了很大的提升,性能是同步日志的十几倍以上。
   ```
    thread_num=1 log_type=sync log_size=100 count=612247 duration=2s qps=306123 
average_time=3287.74us
    thread_num=8 log_type=sync log_size=100 count=453624 duration=2s qps=226812 
average_time=35352.2us
    thread_num=1 log_type=async log_size=100 count=9856504 duration=2s 
qps=4928252 average_time=203.911us
    thread_num=8 log_type=async log_size=100 count=14547148 duration=2s 
qps=7273574 average_time=1104.67us
   ```
   
   Side effects:
   - Performance effects(性能影响):
   
   - Breaking backward compatibility(向后兼容性): 
   
   ---
   ### Check List:
   - Please make sure your changes are compilable(请确保你的更改可以通过编译).
   - When providing us with a new feature, it is best to add related 
tests(如果你向我们增加一个新的功能, 请添加相关测试).
   - Please follow [Contributor Covenant Code of 
Conduct](../../master/CODE_OF_CONDUCT.md).(请遵循贡献者准则).
   


-- 
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: dev-unsubscr...@brpc.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org
For additional commands, e-mail: dev-h...@brpc.apache.org

Reply via email to