halayli / lthread

lthread, a multicore enabled coroutine library written in C
Other
814 stars 82 forks source link

Can using aio instead of multi-threading for asynchronous I/O? #34

Open liexusong opened 9 years ago

liexusong commented 9 years ago

I think using aio better than multi-threading.

TheReverberation commented 3 years ago

I just ran two primitive tests with stdio and a simple complexity calculation of O(1). 100 threads were started using pthreads and lthreads. So, user time: pthreads: ~270ms, lthreads: ~600ms and sys time: 650/350ms accordingly. I want to ask the lthreads community, have you tested the speed of the library in real projects, in particular, have you built an asynchronous server?

wanghaEMQ commented 2 years ago

It is because that context switch needs time. I think lthread is not an out-of-the-box project. It must be changed before being applied. For example. The computed tasks and defer tasks should be separated into other pthreads.

wanghaEMQ commented 2 years ago

@TheReverberation 100 pthreads VS 100 lthreads? or more than 100 lthreads in 100 pthreads? Maybe you can show your code.