I thought I''d throw together a little proof of concept as far as using continuations to mimic a synchronous API. Here''s an echo server: http://pastie.caboo.se/44544 Note the inner loop: loop { send_data read } -- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com (970) 232-4208 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070303/6d4bbf63/attachment.html
On 3/3/07, Tony Arcieri <tony at clickcaster.com> wrote:> I thought I''d throw together a little proof of concept as far as using > continuations to mimic a synchronous API. > > Here''s an echo server: > > http://pastie.caboo.se/44544 > > Note the inner loop: > loop { send_data read }Now, write a little client that feeds data into your server, and you''ll see why Ruby continuations are (unfortunately) impractical. The RAM usage will grow rapidly. I just did it, and feeding 10k lines to the echo server grows RAM usage substantially. 20k lines jumps the RAM usage on my box from a starting point of 8388 to 36004. Kirk Haines
Well, that''s unfortunate - Tony On 3/4/07, Kirk Haines <wyhaines at gmail.com> wrote:> > On 3/3/07, Tony Arcieri <tony at clickcaster.com> wrote: > > I thought I''d throw together a little proof of concept as far as using > > continuations to mimic a synchronous API. > > > > Here''s an echo server: > > > > http://pastie.caboo.se/44544 > > > > Note the inner loop: > > loop { send_data read } > > Now, write a little client that feeds data into your server, and > you''ll see why Ruby continuations are (unfortunately) impractical. > > The RAM usage will grow rapidly. > > I just did it, and feeding 10k lines to the echo server grows RAM > usage substantially. 20k lines jumps the RAM usage on my box from a > starting point of 8388 to 36004. > > > Kirk Haines > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com (970) 232-4208 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070304/112ebcc4/attachment-0001.html
Any idea as to the cause of the leak? Just deficiencies in Ruby''s implementation of continuations, or what? - Tony On 3/4/07, Tony Arcieri <tony at clickcaster.com> wrote:> > Well, that''s unfortunate > > - Tony > > On 3/4/07, Kirk Haines <wyhaines at gmail.com> wrote: > > > > On 3/3/07, Tony Arcieri <tony at clickcaster.com> wrote: > > > I thought I''d throw together a little proof of concept as far as using > > > continuations to mimic a synchronous API. > > > > > > Here''s an echo server: > > > > > > http://pastie.caboo.se/44544 > > > > > > Note the inner loop: > > > loop { send_data read } > > > > Now, write a little client that feeds data into your server, and > > you''ll see why Ruby continuations are (unfortunately) impractical. > > > > The RAM usage will grow rapidly. > > > > I just did it, and feeding 10k lines to the echo server grows RAM > > usage substantially. 20k lines jumps the RAM usage on my box from a > > starting point of 8388 to 36004. > > > > > > Kirk Haines > > _______________________________________________ > > Eventmachine-talk mailing list > > Eventmachine-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/eventmachine-talk > > > > > > -- > Tony Arcieri > ClickCaster, Inc. > tony at clickcaster.com > (970) 232-4208 >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com (970) 232-4208 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070304/63cde0cc/attachment.html
On 3/4/07, Tony Arcieri <tony at clickcaster.com> wrote:> > I thought I''d throw together a little proof of concept as far as using > > > > continuations to mimic a synchronous API. > > > >I apologize if this is a dense question, but isn''t it the case that you can''t really use continuations unless you know you know you can progress the computation by degrees, without blocking? If so, can you use the Deferrable pattern? Otherwise I''d think you''re stuck with threads. -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070304/661bb5fb/attachment.html
Any blocking call made during the "run" loop would starve the EM event loop, if that''s what you mean. Sounds like it''s unworkable anyway due to memory leaks. - Tony On 3/4/07, Francis Cianfrocca <garbagecat10 at gmail.com> wrote:> > On 3/4/07, Tony Arcieri <tony at clickcaster.com> wrote: > > > > > I thought I''d throw together a little proof of concept as far as > > > > using > > > > > continuations to mimic a synchronous API. > > > > > > > > I apologize if this is a dense question, but isn''t it the case that you > can''t really use continuations unless you know you know you can progress the > computation by degrees, without blocking? If so, can you use the Deferrable > pattern? Otherwise I''d think you''re stuck with threads. > > > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com (970) 232-4208 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070304/a9f0b8c5/attachment.html
I thought Ruby continuations were frowned on anyways. Your goal with code like this isn''t real continuation-passing; it''s just coming as close as possible to imperative, procedural code in a callback/state-machine environment. Tcl doesn''t even have continuations; Danny just faked it by being tricky with variable scoping. Note that his syntax suffers, which is a concession to just making it work. I should shut up and just write the Ruby code to show this. On 3/4/07, Kirk Haines <wyhaines at gmail.com> wrote:> On 3/3/07, Tony Arcieri <tony at clickcaster.com> wrote: > > I thought I''d throw together a little proof of concept as far as using > > continuations to mimic a synchronous API. > > > > Here''s an echo server: > > > > http://pastie.caboo.se/44544 > > > > Note the inner loop: > > loop { send_data read } > > Now, write a little client that feeds data into your server, and > you''ll see why Ruby continuations are (unfortunately) impractical. > > The RAM usage will grow rapidly. > > I just did it, and feeding 10k lines to the echo server grows RAM > usage substantially. 20k lines jumps the RAM usage on my box from a > starting point of 8388 to 36004. > > > Kirk Haines > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >
I''d definitely like to check that out - Tony On 3/4/07, Thomas Ptacek <tqbf at matasano.com> wrote:> > I thought Ruby continuations were frowned on anyways. Your goal with > code like this isn''t real continuation-passing; it''s just coming as > close as possible to imperative, procedural code in a > callback/state-machine environment. > > Tcl doesn''t even have continuations; Danny just faked it by being > tricky with variable scoping. Note that his syntax suffers, which is a > concession to just making it work. > > I should shut up and just write the Ruby code to show this. > > On 3/4/07, Kirk Haines <wyhaines at gmail.com> wrote: > > On 3/3/07, Tony Arcieri <tony at clickcaster.com> wrote: > > > I thought I''d throw together a little proof of concept as far as using > > > continuations to mimic a synchronous API. > > > > > > Here''s an echo server: > > > > > > http://pastie.caboo.se/44544 > > > > > > Note the inner loop: > > > loop { send_data read } > > > > Now, write a little client that feeds data into your server, and > > you''ll see why Ruby continuations are (unfortunately) impractical. > > > > The RAM usage will grow rapidly. > > > > I just did it, and feeding 10k lines to the echo server grows RAM > > usage substantially. 20k lines jumps the RAM usage on my box from a > > starting point of 8388 to 36004. > > > > > > Kirk Haines > > _______________________________________________ > > Eventmachine-talk mailing list > > Eventmachine-talk at rubyforge.org > > http://rubyforge.org/mailman/listinfo/eventmachine-talk > > > _______________________________________________ > Eventmachine-talk mailing list > Eventmachine-talk at rubyforge.org > http://rubyforge.org/mailman/listinfo/eventmachine-talk >-- Tony Arcieri ClickCaster, Inc. tony at clickcaster.com (970) 232-4208 -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/eventmachine-talk/attachments/20070304/8d6a5c0a/attachment.html
On 3/4/07, Tony Arcieri <tony at clickcaster.com> wrote:> Any idea as to the cause of the leak? Just deficiencies in Ruby''s > implementation of continuations, or what?AFAIK, yes. It''s a long standing deficiency in the implementation of Ruby continuations. Several years ago there was some discussion about it on ruby-talk, in conjunction with discussion about Borges, which was a ruby clone of SeaSide. As far as I can recall, that''s the last time it has been seriously discussed on ruby-talk. Kirk Haines