Skip to content
New issue

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

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

Already on GitHub? # to your account

使用check机制并不能使cpu使用率下降 #405

Open
Alan-yly opened this issue Feb 27, 2024 · 5 comments
Open

使用check机制并不能使cpu使用率下降 #405

Alan-yly opened this issue Feb 27, 2024 · 5 comments

Comments

@Alan-yly
Copy link
Contributor

微信图片_20240227100527 您好,这一段我认为有问题,因为ikcp_check返回的时间戳永远小于kcp->ts_flush,而ikcp_update只会当kcp->current大于kcp->ts_flush时才会调用ikcp_flush,所以ikcp_check并不能降低ikcp_flush的调用频率,而所有cpu消耗主要集中在ikcp_flush中,所以使用check机制并不能使kcp的cpu消耗下降。
@skywind3000
Copy link
Owner

不是帮你避免 flush,flush 避免不了,而是当你管理成千上万个 kcp 对象时,可以依靠 timer 事件去管理,避免每毫秒干轮询 update/check

@Alan-yly
Copy link
Contributor Author

Alan-yly commented Mar 1, 2024

还有一个问题想请教作者一下,有没有什么比较好的弱网模拟工具?我们现在需要在弱网环境下进行压力测试,之前使用了linux tc做弱网模拟工具,然后发现如果tc设置了延时抖动会存在大量的报文乱序,而且如果流量比较大之后tc又会出现丢包率高于设定值的情况。

@skywind3000
Copy link
Owner

tc 就是最科学的,你流量超过额定值,当然要丢包,

@Alan-yly
Copy link
Contributor Author

Alan-yly commented Mar 1, 2024

但是tc使用netem设置了随机抖动之后会出现大量报文乱序的情况,但是在实际场景中只会出现网络抖动而不会出现大量乱序,这个问题请问作者有没有什么方法解决呢?

@32haojiufangjia
Copy link

关注KCP几年了,直到今天才知道作者设计Check的用意。。。如果你服务器管理了大量连接,然后每帧去对每一个对象执行Update,会浪费一些性能,造成在同一帧延迟太久。然后这个时候如果你看过“时间轮”算法,把时间轮算法结合Check(),你就可以每帧只对一部分对象执行Update,大大减少了浪费。

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

No branches or pull requests

3 participants