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

NewConfigClient调用delayScheduler时传入的delay参数写死为10ms,导致cpu占用高 #311

Closed
bigwhite opened this issue Oct 9, 2021 · 1 comment

Comments

@bigwhite
Copy link

bigwhite commented Oct 9, 2021

使用目前nacos-sdk-go的最新代码,写一个仅与nacos建立连接并监听配置变化但其他啥也不做的小程序,该程序空跑占用2%的cpu。发现NewConfigClient调用delayScheduler时第二个参数写死为10毫秒,这样每秒就要循环100次。将第二个参数改为1s,cpu占用为0 。改为100ms,会有周期性波动,最多是1%,但多数情况都是0。

看之前曾merge过一个pr:https://github.com/nacos-group/nacos-sdk-go/pull/112/commits/58e8ae45d824cf69a0b5f057043f26228b2c57fe,该pr支持设置delayScheduler的delay参数。现在这个pr似乎又被改回去了。

因此,我的问题是:

  1. NewConfigClient调用delayScheduler时传入的delay参数为什么写死为10ms?
  2. 如果我改为100ms或更大,会有什么“伤害”?
@binbin0325
Copy link
Member

binbin0325 commented Oct 9, 2021

10ms 计算一次是否有新的监听任务, delay 越大 监听配置的时机越晚。 后续调整到500ms吧,目前看10ms 也没什么必要

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