Re: Serialized continuation size

"Scott G. Miller" <[email protected]>
Newsgroups gmane.comp.java.sisc.user
Message-ID <[email protected]>
On Thu, Apr 20, 2006 at 03:58:39PM +1200, Lindsay Smith wrote:
> 
> I have just upgraded from sisc 1.8.8 to the latest version 1.13.5 and 
> the size of the serialized continuations in my app has grown slightly.  
> Some testing was done with an alpha version a few iterations ago and it 
> was thought that equivalent continuations had decreased in size, however 
> this doesn't seem to be the case now. 
> 
> What is included when a continuation is stored? Is there anyway to 
> examine the contents of a continuation? Are there any guidelines for 
> ensuring that there is no extraneous state captured?  

The serialized continuation is simply the serialization of the set of 
stack frames that make the continuation up, and any resources they point 
to.  Typically this includes closures on the stack (so, local procedures 
and variables), and references to global variables.  In SISC, a special 
mechanism exists to serialize brief references to data on the heap 
rather than traversing into those heap objects and thus serializing 
large swaths of heap data.  Other, user defined procedures may be 
serialized however.

SISC uses flat closures, which eliminate most junk data in a closure
at any given frame, so you typically do not need to clear references to
unreferenced stack variables.  For example:

(let ([a 3])
  (let ([b 4])
    (lambda () b)))

If the lambda closure is serialized, only the value 4 from the stack
is actually present.  However, you may wish to either clear, or 
lexically exclude variables which you don't want serialized, especially
values such as ports and threads, which can't be serialized anyway.  You
can also put these resources in the dynamic environment (e.g. 
parameters), where they aren't on the stack.  

Be careful to note what is really in a continuation, which are the 
expressions remaining to evaluate.  In the following example, for 
example, a closure exists around the serialization site, but because
the reference to "p" still will be evaluated, it is on the stack and
will be serialized.  

(let ([p (open-output-file "foo")])
  (let () 
    (serialization-occurs-here))
  p)

Make sure that if you are trying to take advantage 
of the flat closures to make sure values aren't in the closure, that 
your closure is in tail position, or that at least the remaining 
expressions don't have references to those values.

(let ([p (make-parameter (open-output-file "foo"))])
  (let ()
    (serialization-occurs-here))
  (p))

In the above example, the output file itself is in the dynamic 
environment, so the serialization is safe.

  Scott

  


-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.