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

锁粒度是不是太大了? #1

Open
barryz opened this issue May 7, 2018 · 1 comment
Open

锁粒度是不是太大了? #1

barryz opened this issue May 7, 2018 · 1 comment

Comments

@barryz
Copy link

barryz commented May 7, 2018

https://github.com/hiberabyss/JustDoIt/blob/master/QPSstatic/QPS_static.go#L30-L39

counter.Timestamp 这个封装个setter方法

counter.CountPerSecond 这个封装个setter、getter方法, 在方法里加锁,这里粒度应该更小吧。

@hiberabyss
Copy link
Owner

Hi @barryz ,

这个实现中并没有太多的考虑性能方面的问题, 后续可以做一些改进, 也欢迎提交 Pull Request :)

感觉优化 ticker 里锁部分的代码意义不大, 毕竟一秒才执行一次. 不过倒是可以考虑用两个锁来分别操作 CountQPS 和 CountAll .

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