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

能否实现一个带缓存池的kcp版本? #8

Closed
jannson opened this issue May 5, 2016 · 8 comments
Closed

能否实现一个带缓存池的kcp版本? #8

jannson opened this issue May 5, 2016 · 8 comments

Comments

@jannson
Copy link

jannson commented May 5, 2016

在路由器里用 golang 都面临着内存问题. Golang 使用内存涨得很快,能否在 NewSegment 那个地方,实现一个内存池,类似使用 sync.Pool 来实现.但是就需要手动释放内存了!

@xtaci
Copy link
Owner

xtaci commented May 5, 2016

不单纯是NewSegment的问题,所有涉及动态内存分配的地方,包括字符串拼接(from.String())都有可能导致内存上涨,小内存真的不太适合带GC的语言。

整体感觉这个问题相当难解决,你可以试试加个定时器,强制runtime.GC(),STW。

@xtaci
Copy link
Owner

xtaci commented May 5, 2016

另外,你可以参考下kcptun,release中有编译好的arm5,6,7,可以尝试在openwrt的路由器上运行观察,我手头没有这样的设备。

@gyf19
Copy link
Contributor

gyf19 commented May 5, 2016

@xtaci 说得有道理. 我有一个pool版本 https://github.com/gyf19/kcp-go , @jannson 也可以测试一下。

@gyf19
Copy link
Contributor

gyf19 commented May 5, 2016

@jannson r8000路由器什么时候出 梅林版本? 急

@xtaci
Copy link
Owner

xtaci commented May 5, 2016

我试过用go-slab来做segment.data的分配

但是,我很难评估其有效性,或许更糟也说不定,我开个分支slab

@bg5sbk
Copy link

bg5sbk commented May 5, 2016

@xtaci 可以试试这个 https://github.com/funny/slab

@jannson
Copy link
Author

jannson commented May 5, 2016

@xtaci 感谢。之前实现一个 p2p 的版本,目前用于远程别人的路由器。未来我重构这个项目的时候我来尝试下。谢谢。

@gyf19 R8000 梅林已经有人在开发了,并且 tomato 版本也有了,中文版本也快了。估计是时间问题而已了。具体咱们就不再这里讨论了,我瞧瞧你提供的项目!感谢。

@jannson jannson closed this as completed May 5, 2016
@jannson
Copy link
Author

jannson commented May 14, 2016

runtime.GC 手动配置运行的话, 也不知道什么时候应该运行.还有就是一运行,整个程序级别的会被 block.(不知道会被 block 多久.)

看到另外一个函数,可以按需多次触发回收.
func SetGCPercent(percent int) int
比如我设置 SetGCPercent(50) 这样.应该让内存不会增长得太快吧

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

No branches or pull requests

4 participants