tnodir / luasys

LuaSys is a portable Lua library providing access to system and networking functions. Also includes: event notification mechanism, win32 specifics (registry, service), serial communication, signals, threading and much more.
http://luaforge.net/projects/luasys
Other
69 stars 24 forks source link

idle tasks #5

Closed richardhundt closed 12 years ago

richardhundt commented 12 years ago

Hi Nodir,

I think luasys needs to have an idle task more than an idle event. You basically want to finish running your all active tasks before servicing I/O.

The echosrvr_co.lua test shows this issue. You only call the scheduler when the event loop is idle. A server under load would starve tasks which are created to process the data. I think this is the wrong way. Instead you want to call the event loop when the scheduler is idle.

What do you think?

Cheers, Richard

tnodir commented 12 years ago

Adding evq.on_idle() callback function was wrong way. I've to remove it and find the way to improve performance of coroutine tasks.

Now callback based echosrvr.lua is much faster than echosrvr_co.lua. And adding on_idle() was bad workaround to avoid threading overheads.

I think to run coroutines (tasks) as callbacks on event-queue and somehow migrate them to scheduler automatically on blocking calls...

tnodir commented 12 years ago

Fixed in tnodir/luasys@3f21c5d6018b5f3356c71ed3a7f8c6f3cff8014b