2016-10-30 ruki
New features Support make command and compile directly without xmake Add switch context interfaces into platform module Add coroutine module (supports i386, x86_64, arm, arm64 ..) Add simple http server demo using coroutine Add simple spider using coroutine Add io poller interfaces(with epoll, poll, kqueue, select) Su 继续阅读 »
2016-12-07 ruki
Stackless introduction Stackfull introduction More coroutine examples New features Support coroutine context switch for mips Add __tb_thread_local__ keyword macro Add --micro=y|n option to compiling micro library (~64K) for the embed system Add tb_addrinfo_addr and tb_addrinfo_name interfaces Add stackless coroutine A 继续阅读 »
2016-10-28 ruki
Introduction Benchbox is a benchmark testing utilities based on xmake and tbox. Build Please install xmake first: xmake bash $ xmake The Coroutine Switch Reports (2 Coroutines) Run bash $ xmake coroutine -n switch Macosx (x86_64) tbox: 10000000 switches in 205 ms, 48780487 switches per sec 继续阅读 »
2016-10-29 ruki
tbox add a coroutine library with stackfull mode and provide the following features. 1. yield 2. suspend and resume 3. sleep 4. io scheduler with (epoll, poll, kqueue, select, poll ..) 5. supports stream, http and other all io modules of tbox 6. channel 7. lock 8. semaphore 继续阅读 »
2016-04-02 Xie Jingyi
写在前面 本文默认读者对 Python 生成器 有一定的了解,不了解者请移步至生成器 - 廖雪峰的官方网站。 本文基于 Python 3.5.1,文中所有的例子都可在 Github 上获得。 学过 Python 的都知道,Python 里有一个很厉害的概念叫做 生成器(Generators)。一个生成器就像是一个微小的线程,可以随处暂停,也可以随时恢复执行,还可以和代码块外部进行数据交换。恰当使用生成器,可以极大地简化代码逻辑。 也许,你可以熟练地使用生成器完成一些看似不可能的任务,如“无穷斐波那契数列”,并引以为豪,认为所谓的生成器也不过如此——那我可要告诉你:这些都太小儿科了,下面我所要介绍的绝对会让你大开眼界。 生成器 继续阅读 »
2016-04-07 Li Shuai
Tornado本身的设计目标是单线程异步非阻塞,要想很好的发挥它的性能最好使用异步IO,并且Tornado本身也提供了异步的AsyncHttpClient的实现,配合gen.coroutine和yield,可以让请求异步执行从而不阻塞当前线程,对于单线程服务器来说,阻塞(blocking)和同步的sleep这种会挂起线程的动作都是服务器的噩梦,因为只有一个线程,所以任何等待都会影响服务器对于其他请求的处理。 异步非阻塞对于第三方IO是http请求的情况还好,毕竟可以使用Tornado提供的异步实现,但是对于有些数据库的IO,则需要异步库的支持,比如针对MongoDB的Motor等。但是第三方异步库的质量也是参差不齐,在实际的工程中 继续阅读 »
2016-06-06 Li Shuai
最不喜欢在Tornado中使用任何同步阻塞型的东西,不想让ioloop阻塞在某个IO调用上,因为单线程的东西任何阻塞都是代价很高的,除非你的数据库被优化的性能很好,速度很快。除了之前的线程池之外,直接使用异步库也是不错的选择,Motor就是Tornado里可以用的很好的异步库,它兼容Tornado的gen.coroutine式的异步调用形式,主要使用了greenlet来巧妙的封装PyMongo的同步API, 把底层的socketIO进行了异步化的处理,化同步为异步。 从使用的例子来分析Motor是如何把PyMongo的API异步化的: client = motor.MotorClient(...) db = client['te 继续阅读 »
2016-12-03 ruki
tbox provides a lightweight implementation of stackless coroutines and it's interfaces are very simple too, for example: c tb_lo_coroutine_enter(coroutine) { while (1) { tb_lo_coroutine_yield(); } } The switch performance of this stackless coroutines is faster than the implementation of tbox's 继续阅读 »
2016-10-28 ruki
简介 Benchbox是一个基准测试包,基于tbox和xmake,里面包含许多针对第三方库功能的性能基准测试和对比,可以很方便的扩展测试用例和模块。 目前内置:各大开源协程库性能基准测试,后续还会陆续增加各种开源库模块的分析测试 测试报告仅供参考,测试代码或者结果上如有问题,可以提交issues 编译 请先安装: xmake 然后运行: bash $ xmake 协程切换测试报告(2个协程) Run bash $ xmake coroutine -n switch Macosx (x86_64) tbox: 10000000 switches in 205 ms, 4 继续阅读 »
2016-07-07 ruki
xmake通过import接口,可以在自定义脚本中导入各种内置类库和扩展类库模块,使得xmake的插件开发具有更多的灵活性,提供更丰富的功能。 我们先看下,目前xmake提供的一些类库: . ├── _g.lua ├── assert.lua ├── catch.lua ├── coroutine.lua ├── debug.lua ├── finally.lua ├── format.lua ├── ifelse.lua ├── import │   └── core │   ├── base │   │  继续阅读 »