Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gossdb Client 性能问题 #12

Open
songliwei2014 opened this issue May 17, 2017 · 4 comments
Open

gossdb Client 性能问题 #12

songliwei2014 opened this issue May 17, 2017 · 4 comments

Comments

@songliwei2014
Copy link

image

@songliwei2014
Copy link
Author

songliwei2014 commented May 17, 2017

最近使用gossdb driver,发现一个性能瓶颈问题。使用MultiHgetAllSlice 获取整张hash map 时,请求量1次每秒,cpu飙到600%, 内存占用1GB,当前使用go1.8 编译,使用go1.7编译时,内存直接暴涨到3GB。然后go tool pprof 查看cpu,问题出现在func (c *Client) parse() []string 这个函数。
内存分析:

(pprof) top
680.71MB of 681.37MB total (99.90%)
Dropped 147 nodes (cum <= 3.41MB)
Showing top 10 nodes out of 24 (cum >= 397.59MB)
      flat  flat%   sum%        cum   cum%
  352.59MB 51.75% 51.75%   352.59MB 51.75%  bytes.makeSlice
  170.99MB 25.09% 76.84%   170.99MB 25.09%  runtime/pprof/internal/protopprof.TranslateCPUProfile
   95.19MB 13.97% 90.81%    95.19MB 13.97%  internal/pprof/profile.(*Profile).preEncode
   28.52MB  4.19% 95.00%    28.52MB  4.19%  runtime.rawstringtmp
   16.95MB  2.49% 97.48%    16.95MB  2.49%  internal/pprof/profile.encodeVarint
   16.48MB  2.42% 99.90%       45MB  6.60%  github.com/ssdb/gossdb/ssdb.(*Client).parse
         0     0% 99.90%   352.59MB 51.75%  bytes.(*Buffer).Write
         0     0% 99.90%   352.59MB 51.75%  bytes.(*Buffer).grow

请问一下这个是否可以优化一下呢?

@ideawu
Copy link
Contributor

ideawu commented May 18, 2017

代码还有优化的空间。

另外,不建议一次获取 hash 的全部内容,应该通过分页遍历,一次获取1000条记录为佳。

@songliwei2014
Copy link
Author

OK,我获取的hash 大小一般都比较小,不超过200条,当前我尝试优化了一下,先pprof 看一下效果,如果不错,再提交给你review 一下。

@songliwei2014
Copy link
Author

我重新提交了是个pull request ,麻烦帮忙review 一下。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants