Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Fine-grained locals clearing
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Rich Hickey  
View profile  
 More options Dec 10 2009, 9:10 am
From: Rich Hickey <richhic...@gmail.com>
Date: Thu, 10 Dec 2009 06:10:44 -0800 (PST)
Local: Thurs, Dec 10 2009 9:10 am
Subject: Fine-grained locals clearing
One of the objectives of Clojure is to reduce incidental complexity.
And one of the biggest sources of incidental complexity in Clojure was
the retention of the head of a lazy sequence due to its being
referenced by some local (argument or local (let) binding). One might
expect that, if no subsequent code in the body of a function uses that
arg/local, it would be subject to GC. Unfortunately, on the JVM, that
is, in many cases, not true - the local is considered a live reference
and is thus not GCed. This yields the infamous 'holding onto the head'
problem, and subsequent Out Of Memory errors on large data sets.

I had put in place a workaround, which was the 'clearing/nulling-out'
of locals on the tail call of the function. This helps in many, but
not all, cases. Not all logic flows are amenable to rearrangement to
leverage this cleanup. And there are many cases where the local is not
visible - e.g. when destructuring.

The full solution is to track, during compilation, the lifetime of all
locals on all branches of the execution path and to emit code that
clears them at the point of last use in any particular branch.

I'm happy to announce I have implemented this fine-grained locals
clearing in the compiler, in the 'new' branch. It should automatically
cover all cases in which the code doesn't explicitly reuse the head -
including non-tail usage, destructuring etc. In short, such cases
should 'just work' from now on.

N.B. that this is strictly a lifetime management issue and does not
change the nature of lazy sequences - they are real, linked data
structures, the tail of which might not yet have been created. They
are most emphatically *not* ephemeral streams of values. However, with
fine-grained locals clearing, they are subject to GC 'as you go',
delivering the benefits of both.

If you've got a pet case of incidental head-retention, please try out
the 'new' branch and let me know how it goes.

Thanks,

Rich


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.