RE: FFI, cURL and function callback

  • From: William Adams <william_a_adams@xxxxxxx>
  • To: "luajit@xxxxxxxxxxxxx" <luajit@xxxxxxxxxxxxx>
  • Date: Wed, 27 Mar 2013 11:19:57 +0000

More Direct:  LuaSocket is too string heavy for my uses.  One of the reasons 
why node.js is so good in terms of performance is that at the very lowest 
levels, you deal with buffers, and don't allocate anything if at all possible.  
LuaSocket requires things to be lua strings, which in a lot of cases will force 
me to make a copy of stuff that was already in a plain old ordinary buffer.

If I were to 'improve' it, I'd also look at the Windows implementation.  
select() is not the best thing to use these days, but rather WSAPoll().

If I were to rewrite LuaSocket from scratch today, thinking only of LuaJIT, I 
would start with ljsyscall, or a similar FFI based shim for the lowest level 
parts, and build up from there.  That would get all the low level socket stuff, 
without any C code.

Then I would rebuild the modules, such as mime, as pure lua code.  I believe 
the ease in building these modules would outweigh any performance loss, 
especially if things are built around buffers rather than strings.

I would build with a scheduler in mind, perhaps one that could be used 
generically, and deal with timers and other events, where socket i/o is just 
one form of event.

It's hard to conceive of building up from the existing codebase.  When I want 
to add SSL, WebSocket, SPDY, etc, I can't really imagine doing that in a highly 
performant manner based on the constraints of the current system.

-- William
===============================
- Shaping clay is easier than digging it out of the ground.


----------------------------------------
> Date: Wed, 27 Mar 2013 11:50:10 +0200
> Subject: Re: FFI, cURL and function callback
> From: steve.j.donovan@xxxxxxxxx
> To: luajit@xxxxxxxxxxxxx
>

>
> Part of the fragmentation problem of Lua comes from excessive good
> manners ;) I don't mean we need to be ruder, simply more direct.
>                                         

Other related posts: