[plt-scheme] overhead of lots of dynamic closure creation in high-performance environment?

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Wed Feb 11 09:18:03 EST 2009

At Wed, 11 Feb 2009 09:09:05 -0500, Neil Van Dyke wrote:
> Is there any rule-of-thumb I could use when reasoning about the 
> performance implications of using lots of dynamic creation of closures 
> and one-shot application of them?

As allocations go, closure creation is fast. It's inlined by the JIT,
for example.

The cost of a closure allocation is proportional to the number of
locally bound variables that are captured by the closure. (References
to top-level or module-level bindings are chunked into a single slot
within the closure.)

> So, for each Web page served, this part of the processing would 
> typically involve, say, 30 closures created dynamically, applied once, 
> and immediately left for GC.

I expect that serving a web page involves so much allocation that 30
closure creations is negligible.


Posted on the users mailing list.