libgsc(Game Server Communication Library)(四)
来源:互联网 发布:jsp网站源码 编辑:程序博客网 时间:2024/05/16 07:12
作了一个简单的测试.
大约是这样一个流程,
1. 在gas进程中开启了4个NetInit, 也就是使用4个actor来处理网络初始消息. 当然, 对api作了些小改动.
void regNetInitActor(vector<Actor*>* netinits); /** 注册网络上与actor无关的消息处理器列表. */
原来是一个, 现在做成了多个.
2. 描述字限制在12000个, 实际上客户端开启了10000个tcp连接.
3. 全部代码使用-g3 -O3编译, 没有strip.
4. libgsc运行在一个i5四核的cpu上. 普通组装PC机.
5. 客户端代码如下:
10000个连接, 报文大小是22个字节. 期望每1/20毫秒发送一个报文.
public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException{byte by[] = new byte[] { 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0A, 0x03, 0x6B, 0x65, 0x79, 0x12, 0x03, 0x65, 0x78, 0x74 };DataOutputStream dos[] = new DataOutputStream[10000];for (int i = 0; i < dos.length; ++i)dos[i] = new DataOutputStream(new Socket("192.168.1.117", 9000).getOutputStream());while (true){for (int i = 0; i < dos.length; i++){dos[i].write(by);if ((i % 20) == 0)Thread.sleep(1);}}}
测试结果是:
1. 连接数, 监听在9000端口上.
2. 实际的消息量.
大约是 14 * 1000条消息/秒, 换算成字节是 14000 * 22 / 1024 ~= 300K字节/s
日志打印代码如下.
ushort NetInit::gcgas_msg_auth(NetInit* ni, Trans* trans, Msg* msg, GasAuthReq* req){ static ullong count = 0; __sync_fetch_and_add(&count, 1); if (count % 1000 == 0) LOG_DEBUG("total message: %llu\n", count) return GX_RET_SUCCESS;}
3. cpu与内存占用情况.
图中一共是19个线程(top -p 24091 -H), libgsc编译时指定了16个工作线程, 所以从下图可推测出:
a). 3个未占用cpu的线程应该是一个main线程, 一个Db线程, 一个是actorAuto线程.
b). 占用cpu 3~5%左右, 是12个工作线程, 负载来自它们在管道上的操作.
c). 最上面4个, cpu 11 ~ 13%, 应该就是四个NetInit所附着的线程.
内存的占用是69M. 性能咋样呢?
0 0
- libgsc(Game Server Communication Library)(四)
- libgsc(Game Server Communication Library)(二)
- libgsc(Game Server Communication Library)(三)
- libgsc(Game Server Communication Library)(五)
- 一个轻量级Actor并发框架的c++实现, libgsc(Game Server Communication Library)(一)
- inter portlet communication library
- LJ-V7000 Series Communication Library
- Network Game - Network Communication Model 1
- Network Game - Network Communication Model 2
- Network Game - Network Communication Model 3
- Network Game - Network Communication Model 4
- Network Game - Network Communication Model 5
- [书籍]《Programming Flash Communication Server》
- Macromedia Flash Communication Server MX
- Flash Communication Server笔记一
- Flash Communication Server笔记二
- flash communication with java server
- Communication error with Jack server
- LeetCode Spiral Matrix II
- mysql 安装 mysql-5.1.73-linux-x86_64-glibc23
- 智能指针share_ptr使用过程中需要注意的几点
- svn merge 撤销 已提交的修改
- DOS下查看某服务是否开启
- libgsc(Game Server Communication Library)(四)
- analogClock时间对话框的使用
- Cocos2d - x学习笔记 [1] 导演、舞台、精灵、层
- 【centos7】 JDK
- 软件工程之软件开发
- HDOJ 4687 Boke and Tsukkomi 一般图最大匹配带花树+暴力
- iOS plist文件删除怎么办
- Windows 7远程桌面连接Ubuntu 14.04
- HDU2133 What day is it 模拟题