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

Bug: PID被假定为不能超过102400 #5

Open
zqdai opened this issue Nov 17, 2016 · 2 comments
Open

Bug: PID被假定为不能超过102400 #5

zqdai opened this issue Nov 17, 2016 · 2 comments

Comments

@zqdai
Copy link

zqdai commented Nov 17, 2016

co_routine.cpp:

static stCoRoutineEnv_t* g_arrCoEnvPerThread[ 102400 ] = { 0 };

采用数组的好处显而易见,但以pid索引这个数组很可能越界。需要该为其他数据结构。

@liaobinxu
Copy link

没看过代码,字面意思每个线程共享的协程数组。
引用<<单易用高性能的协程库http://mp.weixin.qq.com/s/bCWM6ncUseEDpynlBvT8hA>>文章中"我们通过libco共享栈模式创建1千万的协程(E5-2670 v3 @ 2.30GHz * 2, 128G内存),每10万个协程共享的使用128k内存,整个稳定echo服务的时候总内存消耗大概为66G。”

@messi824
Copy link

messi824 commented Nov 29, 2016

引用google结果:一般PID_MAX=0x8000(可改),因此进程号的最大值为0x7fff,即32767。
这里最新的版本好像已经改为204800,越界的概率基本为0。当然,这里这样写,感觉有些不太优雅。

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

3 participants