{"action":"created","issue":{"url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/38","labels_url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/38/labels{/name}","comments_url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/38/comments","events_url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/38/events","html_url":"https://github.com/baidu/sofa-pbrpc/pull/38","id":117383191,"number":38,"title":"support for adding multiple io_service objects","user":{"login":"cyshi","id":7066978,"avatar_url":"https://avatars.githubusercontent.com/u/7066978?v=3","gravatar_id":"","url":"https://api.github.com/users/cyshi","html_url":"https://github.com/cyshi","followers_url":"https://api.github.com/users/cyshi/followers","following_url":"https://api.github.com/users/cyshi/following{/other_user}","gists_url":"https://api.github.com/users/cyshi/gists{/gist_id}","starred_url":"https://api.github.com/users/cyshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyshi/subscriptions","organizations_url":"https://api.github.com/users/cyshi/orgs","repos_url":"https://api.github.com/users/cyshi/repos","events_url":"https://api.github.com/users/cyshi/events{/privacy}","received_events_url":"https://api.github.com/users/cyshi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-11-17T15:45:54Z","updated_at":"2015-11-19T14:04:19Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/baidu/sofa-pbrpc/pulls/38","html_url":"https://github.com/baidu/sofa-pbrpc/pull/38","diff_url":"https://github.com/baidu/sofa-pbrpc/pull/38.diff","patch_url":"https://github.com/baidu/sofa-pbrpc/pull/38.patch"},"body":"# 支持用户设置多个io_service\r\n\r\n## 主要改动点\r\n\r\n* 增加了io_service_pool，io_service的选择策略使用round robin\r\n\r\n* `RpcSeverOptions` 中增加了用户设置io_service数量的选项\r\n\r\n* (update) 增加了`TimeProvider`，在一个线程中专门提供时间\r\n\r\n## TODO\r\n\r\n* ~~ptime_now 暂时没有改动~~\r\n\r\n* 性能及功能测试报告，性能测试时需要关闭tcp_no_delay，以及链编tcmalloc\r\n\r\n## 需要讨论\r\n\r\n* 目前Server Options中默认的选项是，8个工作线程，分享1个io_service，这样做是为了与之前的效果保持一致，用户升级无感知，但是work_thread_num的含义反生了变动，不知道用户对此会不会有误解。此外，之所以保留两个选项对外开放主要是考虑对于一些 **long-running** 操作，用户可能需要设置不同的io_service数量以及共享io_serivce的线程数量，此时因为io_service的LF模型，可能多线程共享一个io_service更合理\r\n\r\n* ptime_now 函数设计，准备单独一个线程专门用来获取当前时间，此线程会对时间做一个缓存，其他线程需要获取时间时都直接从这个线程取出，时间精度准备做成1ms\r\n\r\n以上两点，辛苦 @qinzuoyan @bluebore 看看\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/comments/158065087","html_url":"https://github.com/baidu/sofa-pbrpc/pull/38#issuecomment-158065087","issue_url":"https://api.github.com/repos/baidu/sofa-pbrpc/issues/38","id":158065087,"user":{"login":"cyshi","id":7066978,"avatar_url":"https://avatars.githubusercontent.com/u/7066978?v=3","gravatar_id":"","url":"https://api.github.com/users/cyshi","html_url":"https://github.com/cyshi","followers_url":"https://api.github.com/users/cyshi/followers","following_url":"https://api.github.com/users/cyshi/following{/other_user}","gists_url":"https://api.github.com/users/cyshi/gists{/gist_id}","starred_url":"https://api.github.com/users/cyshi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cyshi/subscriptions","organizations_url":"https://api.github.com/users/cyshi/orgs","repos_url":"https://api.github.com/users/cyshi/repos","events_url":"https://api.github.com/users/cyshi/events{/privacy}","received_events_url":"https://api.github.com/users/cyshi/received_events","type":"User","site_admin":false},"created_at":"2015-11-19T14:04:18Z","updated_at":"2015-11-19T14:04:18Z","body":"多谢 @skyan 的建议\r\n\r\n* 测试发现使用universal_time的极限性能在55w左右，其中处理时区的部分应该是有加锁，去掉之后性能可以达到110w左右；之所以增加线程获取时间，而没有直接使用`clock_gettime`主要是因为目前pbrpc中的时间计算都是基于ptime进行的，而timespec并没有很好的办法转成ptime，所以只增加一个线程，对目前的代码修改最少\r\n\r\n* Linux平台下定时的精度并不高，usleep和nanosleep都尝试过，不过还是打算换掉usleep"}}