会员
周边
新闻
博问
闪存
众包
赞助商
Chat2DB
所有博客
当前博客
我的博客
我的园子
账号设置
会员中心
简洁模式
...
退出登录
注册
登录
napoleon_liu
博客园
首页
新随笔
联系
管理
订阅
上一页
1
···
8
9
10
11
12
13
14
15
16
17
下一页
2010年8月9日
您可能不知道的 C++ 关键字
摘要: C++ 有些操作符,其实有对应的关键字(目的是为了在没有这些字符的键盘也可以输入C++程序) [代码]从可读性的角度看, and, not ,or 比操作符更好。
阅读全文
posted @ 2010-08-09 17:17 napoleon_liu
阅读(190)
评论(0)
推荐(0)
2010年8月7日
taskset 和 smp_mask 提高程序效率
摘要: 多核机器运行程序时,如果经常进程切换会损失效率。taskset -c 0,1,3 ./your_program 可以让你的程序只在0,1,3这3个CPU上运行。cat /proc/interrupts 查看你网卡的中断号,比如是209.那么设置 echo b > /proc/irq/209/smp_mask 这样就让网卡只中断2号CPU。经过测试,这样可以提高1K/s 吞吐。
阅读全文
posted @ 2010-08-07 23:30 napoleon_liu
阅读(460)
评论(0)
推荐(0)
Michael &Scott 无锁队列 C++ 实现
摘要: 最近在研究无锁算法, 参照Michael and Scott的伪码,实现了个c++版本。参考 http://www.cs.rochester.edu/research/synchronization/pseudocode/queues.html 伪代码是:Code highlighting prod...
阅读全文
posted @ 2010-08-07 09:53 napoleon_liu
阅读(7841)
评论(13)
推荐(1)
2010年8月2日
网络编程中的超时机制
摘要: 调用级超时 阻塞IO的超时使用alert信号,可以打断所有的系统调用,包括socket io; recv, send 还可以设置socket 选项(SO_RCVTIMEO, SO_SNDTIMEO )来实现超时;connect 调用系统本身提供了75秒的超时。非阻塞模拟: select 一个socket 来模拟阻塞操作。 为什么要这样做的呢? [多线程处理alert信号比较麻烦(信号是进程全局共享...
阅读全文
posted @ 2010-08-02 18:02 napoleon_liu
阅读(1381)
评论(0)
推荐(1)
2010年7月28日
coroutine
摘要: coroutine 分 symmetry coroutine(yeild_to 方式) 和 asymmetry coroutine(yeild , resume).实现方式有: Duff device 的stack-base 方式,state变量和switch或goto实现。(参考 http://www.chiark.greenend.org.uk/~sgtatham/coroutines.htm...
阅读全文
posted @ 2010-07-28 10:45 napoleon_liu
阅读(399)
评论(0)
推荐(0)
2010年7月27日
以string为键值的容器
摘要: http 的 header和 params最方便的储存方式就是使用 map<string,string>. 以前我也一直这么做,但最近用gprof后发现这是个很耗cpu的容器。在header和params确定且数量不多的时候,改用vector和find方式反而速度更快(提升有3倍),因为map的构造比较耗时,少数据量查找也没有优势(vector的结构简单且内存连续,少数据量是反而更快)...
阅读全文
posted @ 2010-07-27 22:58 napoleon_liu
阅读(641)
评论(1)
推荐(0)
2010年7月20日
LT自动挡,ET手动挡(epoll)
摘要: epoll有 ET和LT两种模式, 默认是LT模式。LT模式的时候,epoll_wait 会把有事件的 file 再次加到 rdllist 列表中,以便下次epoll_wait可以再检查一遍。 if (epi->event.events & EPOLLONESHOT) epi->event.events &= EP_PRIVATE_BITS; else if (!(ep...
阅读全文
posted @ 2010-07-20 17:59 napoleon_liu
阅读(4483)
评论(1)
推荐(2)
2010年7月19日
[转] epoll 实现
摘要: 转自: http://hi.baidu.com/rwen2012/blog/item/0f2f8c13eb7f3621dd5401a8.html/* * This structure is stored inside the "private_data" member of the file * structure and rapresent the main data sructure fo...
阅读全文
posted @ 2010-07-19 23:10 napoleon_liu
阅读(750)
评论(0)
推荐(0)
2010年7月16日
网络并发 工作经验总结(2W/S级别吞吐)
摘要: 协议设计原则:第一条 使用文本协议, 尽量使用http协议;(文本协议利于调试和测试,也利于脚本使用, http协议成熟,比较多工具支持)第二条 如果效率成为问题,可以在实现了文本协议之后,支持二进制协议;(这样程序的BUG可以用文本协议及早发现,后来调试也更方便);第三条 选择二进制协议时(protocal_buffer, memcache协议, MessagePack),考虑脚本语言的兼容...
阅读全文
posted @ 2010-07-16 00:37 napoleon_liu
阅读(2267)
评论(2)
推荐(2)
2010年6月12日
libevent 之epoll 观后感
摘要: libevent支持很多系统,因本人是做Linux后台的,故只看了epoll部分。 eventops 数组用来实现devpoll, kqueue, epoll, poll, select 实现的选择。 event_base * current_base; libevent 主要控制结构。 event_base 分3个队列 EVLIST_INSERTED, EVLIST_ACTIVE, EVL...
阅读全文
posted @ 2010-06-12 20:24 napoleon_liu
阅读(7626)
评论(0)
推荐(1)
上一页
1
···
8
9
10
11
12
13
14
15
16
17
下一页
公告