This morning, I added support for continuation-based programming to Wee.
It's now one step closer to Seaside2 or Borges. But I still support
non-continuation-based apps. After changing half a dozen of lines, it was
done, or so I thought. But then, I realized that you can't call
continuations across threads. After wrapping each session into it's own
thread and communicating with the application via two queues, and setting
Thread.abort_on_exception=true to find some minor bugs, it really
worked!
The rest of the day I fighted against some memory issues. To detect them, I
was in the need for a simple stress testing application. Thus, I patched WebUnit, to support
redirects and <br/> tags, then wrote a memory observer with GNUplot
output and finally the stress tester.
I run the tests with all recent versions of Ruby, then I realized that the
leak must be in my program and not in Ruby. More or less quickly I
discovered that I had a reference back to the continuation in the called
component, which resulted in the continuation not being freed as the
continuatin has itself a reference to the component on the procedure stack.
Assigning nil fixed the bug.
Below is the memory usage of Wee with continuations running under
ruby-current as of today. I stressed it with 50 processes, i.e. 50 active
sessions (= 50 Ruby threads), and a total of 100000 requests (in 10
minutes). It stayed below 22MB, that's 500kB per session. It still slightly
increases over the time, not sure whether this is GC related or not
(fragmentation?). I'll have to stress it over night ;-)