-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
handle message session wrap around #1797
Conversation
如果你平均一秒1w次call 要持续 59小时才会回绕, 没有什么游戏业务能忍受 59小时的延迟吧。 就算你瞬间达到 21亿次call,一个lua协程大概占用1KB内存, 大概需要2T的内存,估计是先OOM. |
是特定用法。比如 |
我要想想有没有别的解决方案,我倾向于不改大到 64bits 。 |
想了还有个方案是把 |
因为只有两个地方会自动分配 id ,一个是 send 传 nil ,一个是 timeout 。 我觉得可以简单实现的方法是:每次分配完 id 回到 lua 层后,把返回的 session + 1 看看后一个会不会和过去的冲突,如果冲突,就故意再分配一个跳过去。 而且,上面的操作可以通过封装 send 函数完成。在 session 还没有回绕时,不启用检查。发现回绕或后,再通过 lua 函数替换掉有检查的版本。 |
没有回绕时不启用检查,回绕后再替换,这个没有太理解。先按上面那样改了一版。 |
因为大部份服务不会活到 session 回绕,所以检查是没有意义的。只需要发现回绕后,替换成这个带检查版本的 send 就可以了。 |
= = 还是想不明白怎么做到。 |
session 目前只有
int32_t
。如果项目中使用skynet.call
,并且对端服务通过skynet.response
hold 住返回值,那 session 回绕后这部分skynet.call
可能被错误唤醒了。(应该不会错误唤醒, 但是 session 上下文被覆盖了,后续报 unknown session)sizeof(struct skyent_message)
会由 24 字节变为 32 字节。不过看了下 jemalloc 16~32 字节间没有其他 sizeclass,应该最终内存也没有啥变化。