Evented I/O ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
13 messages Options
Reply | Threaded
Open this post in threaded view
|

Evented I/O ?

drush66
Hi I was wondering, is there event based I/O for Pharo?

Something like nio in java or EventMachine for Ruby?

Many thanks,

Davorin Rusevljan
http://www.cloud208.com/

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

Stéphane Ducasse
Can you describe what they are doing?

Stef

On Aug 31, 2011, at 8:58 AM, drush66 wrote:

> Hi I was wondering, is there event based I/O for Pharo?
>
> Something like nio in java or EventMachine for Ruby?
>
> Many thanks,
>
> Davorin Rusevljan
> http://www.cloud208.com/
>
>
>
> --
> View this message in context: http://forum.world.st/Evented-I-O-tp3780350p3780350.html
> Sent from the Pharo Smalltalk Users mailing list archive at Nabble.com.
>


Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
On Wed, Aug 31, 2011 at 9:34 AM, Stéphane Ducasse
<[hidden email]> wrote:
> Can you describe what they are doing?

Well, they do not do it in exactly the same way, but async I/O is used
in servers that need to handle very large number of connections (like
web servers, message queues), and where cost of separate process or
even a thread for each connection is too large. So instead of
providing blocking api, and having a thread for each connection
waiting in a blocking call, those frameworks allow for handling of all
connections in side one thread. Quite often this is done with
registering callbacks that handle events for a connection that
framework efficently calls, but other approaches also exist.

For far better explanation wikipedia gives nice overview:

http://en.wikipedia.org/wiki/Asynchronous_I/O

The techniques exist fro a long time, but an article that triggered
wider interest and defined C10k term is here:

http://www.kegel.com/c10k.html

Nginx web server is one example of usage of Async I/O

Davorin Rusevljan
http://www.cloud208.com/

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

Marcus Denker-4
In reply to this post by Stéphane Ducasse

On Aug 31, 2011, at 10:07 AM, Davorin Rusevljan wrote:

> On Wed, Aug 31, 2011 at 9:34 AM, Stéphane Ducasse
> <[hidden email]> wrote:
>> Can you describe what they are doing?
>
>
> Nginx web server is one example of usage of Async I/O


I wonder sometimes... Node.js seems to be a wrapper around a
C-Library that provided async IO for all platforms. Wouldn't it be
possible to provide binding for the C part of Node-JS and use
that for async/Event based IO?

        Marcus


--
Marcus Denker -- http://marcusdenker.de


Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
On Wed, Aug 31, 2011 at 10:11 AM, Marcus Denker <[hidden email]> wrote:
> I wonder sometimes... Node.js seems to be a wrapper around a
> C-Library that provided async IO for all platforms. Wouldn't it be
> possible to provide binding for the C part of Node-JS and use
> that for async/Event based IO?

I think node.js uses libev:

http://software.schmorp.de/pkg/libev.html

I am out of depth here, but I suspect it might be a bit more difficult
to wrap it than some classic library, since it might need to play
nicely with VM.

Davorin

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

David T. Lewis
On Wed, Aug 31, 2011 at 10:17:02AM +0200, Davorin Rusevljan wrote:

> On Wed, Aug 31, 2011 at 10:11 AM, Marcus Denker <[hidden email]> wrote:
> > I wonder sometimes... Node.js seems to be a wrapper around a
> > C-Library that provided async IO for all platforms. Wouldn't it be
> > possible to provide binding for the C part of Node-JS and use
> > that for async/Event based IO?
>
> I think node.js uses libev:
>
> http://software.schmorp.de/pkg/libev.html
>
> I am out of depth here, but I suspect it might be a bit more difficult
> to wrap it than some classic library, since it might need to play
> nicely with VM.
>
> Davorin

Are you talking about signaling the image when an IO event happens?
If so, see http://wiki.squeak.org/squeak/3384. The plugin is included
in standard unix VMs.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
On Thu, Sep 1, 2011 at 2:16 AM, David T. Lewis <[hidden email]> wrote:
> Are you talking about signaling the image when an IO event happens?
> If so, see http://wiki.squeak.org/squeak/3384. The plugin is included
> in standard unix VMs.

thanks for the pointer!, I will look into it. By the name it sounds
like it might be it, but docs mention signaling process which might
imply smalltalk process per connection.

Davorin Rusevljan
http://www.cloud208.com/

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

Stéphane Ducasse
In reply to this post by Marcus Denker-4
Indeed it would be good to get a try at such solution.

>>> I wonder sometimes... Node.js seems to be a wrapper around a
> C-Library that provided async IO for all platforms. Wouldn't it be
> possible to provide binding for the C part of Node-JS and use
> that for async/Event based IO?

Stef


Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
In reply to this post by David T. Lewis
On Thu, Sep 1, 2011 at 2:16 AM, David T. Lewis <[hidden email]> wrote:
> Are you talking about signaling the image when an IO event happens?
> If so, see http://wiki.squeak.org/squeak/3384. The plugin is included
> in standard unix VMs.


I did a quick peek, if not perfect, it might be of much help.

On positive side:
- it allows for async work with files and sockers

On might be improved side:
- it depends on select call which in it self is not perfect for large
number of file descriptors (like thousand(s))
- it seems to require Smalltalk process for each file desciptor, and
ProcessScheduler might also not be happy with thousands of smalltalk
processe
- unix only.

Anyway, even so:
- it will still probably be much better than synchronous way of doing things.
- it might be used to experiment, design and prototype nice callback
based API on the Smalltalk side.

Thanks!

Davorin Rusevljan
http://www.cloud208.com/

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

Stéphane Ducasse
I would really that somebody run an experience on wrapping some good unix async library.

Stef

> Are you talking about signaling the image when an IO event happens?
>> If so, see http://wiki.squeak.org/squeak/3384. The plugin is included
>> in standard unix VMs.
>
>
> I did a quick peek, if not perfect, it might be of much help.
>
> On positive side:
> - it allows for async work with files and sockers
>
> On might be improved side:
> - it depends on select call which in it self is not perfect for large
> number of file descriptors (like thousand(s))
> - it seems to require Smalltalk process for each file desciptor, and
> ProcessScheduler might also not be happy with thousands of smalltalk
> processe
> - unix only.
>
> Anyway, even so:
> - it will still probably be much better than synchronous way of doing things.
> - it might be used to experiment, design and prototype nice callback
> based API on the Smalltalk side.
>
> Thanks!
>
> Davorin Rusevljan
> http://www.cloud208.com/
>


Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

David T. Lewis
In reply to this post by drush66
On Thu, Sep 01, 2011 at 09:10:40AM +0200, Davorin Rusevljan wrote:

> On Thu, Sep 1, 2011 at 2:16 AM, David T. Lewis <[hidden email]> wrote:
> > Are you talking about signaling the image when an IO event happens?
> > If so, see http://wiki.squeak.org/squeak/3384. The plugin is included
> > in standard unix VMs.
>
>
> I did a quick peek, if not perfect, it might be of much help.
>
> On positive side:
> - it allows for async work with files and sockers

Files, sockets, pipes. Anything that looks like a file descriptor
on unix.

>
> On might be improved side:
> - it depends on select call which in it self is not perfect for large
> number of file descriptors (like thousand(s))

Yes, the plugin provides a hook into the underlying aio mechanism in the VM.

> - it seems to require Smalltalk process for each file desciptor, and
> ProcessScheduler might also not be happy with thousands of smalltalk
> processe

Yes.

If you want to put a load on the aio plugin, try running the CommandShell
unit test suite with a standard unix interpreter VM.

> - unix only.
>

Yes.

It will work on OS X also, but the plugin is not usually distributed
on those VMs. There is no implementation for Windows.

> Anyway, even so:
> - it will still probably be much better than synchronous way of doing things.
> - it might be used to experiment, design and prototype nice callback
> based API on the Smalltalk side.
>
> Thanks!
>
> Davorin Rusevljan
> http://www.cloud208.com/

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
On Thu, Sep 1, 2011 at 2:16 PM, David T. Lewis <[hidden email]> wrote:
> It will work on OS X also, but the plugin is not usually distributed
> on those VMs. There is no implementation for Windows.

just a dummy question, does plugin also work under the Cog VM?

davorin

Reply | Threaded
Open this post in threaded view
|

Re: Evented I/O ?

drush66
In reply to this post by Stéphane Ducasse
On Thu, Sep 1, 2011 at 9:56 AM, Stéphane Ducasse
<[hidden email]> wrote:
> I would really that somebody run an experience on wrapping some good unix async library.

I am working on the AMQP 1.0 client library (AMQP is a message queue
specification), and using async io, and providing event based api for
the AMQP library (using reactor pattern like in ruby's  Event Machine)
would be great.

I might try to implement small event machine, and use it to both wrap
AioPlugin, and to wrap interface to AMQP.. But I'll make no big
proomises.:)

Davorin Rusevljan
http://www.cloud208.com/