Lazy defn loading

30 views
Skip to first unread message

Rich Hickey

unread,
Apr 4, 2011, 7:39:19 AM4/4/11
to cloju...@googlegroups.com
I added lazy defn loading as an experiment:

https://github.com/clojure/clojure/commit/71930b6b6537a796cdf13c4ffa7cf93eb53b6235

and am looking for feedback. Is it improving your startup times, or
causing any problems?

Rich

Sean Corfield

unread,
Apr 4, 2011, 9:44:41 PM4/4/11
to cloju...@googlegroups.com

A user reported a problem on the main clojure list that they believed
was related to this change:

http://groups.google.com/group/clojure/browse_thread/thread/c9276d8e72c26a6a?hl=en#

If you have let-over-defn and the defn doesn't use any of the bindings
in the let, you get an exception when you call the function:

(let [a 1] (defn foo[x] (+ a x)))
(foo 1) ;; works

(let [a 1] (defn foo[x] (+ 1 x)))
(foo 1) ;; throws: ClassNotFoundException user$eval75$foo__76
java.lang.Class.forName0 (Class.java:-2)

I confirmed that the second form works in the alpha4 build but fails
as shown in alpha6.
--
Sean A Corfield -- (904) 302-SEAN
An Architect's View -- http://corfield.org/
World Singles, LLC. -- http://worldsingles.com/
Railo Technologies, Inc. -- http://www.getrailo.com/

"Perfection is the enemy of the good."
-- Gustave Flaubert, French realist novelist (1821-1880)

Andy Fingerhut

unread,
Apr 5, 2011, 2:42:39 AM4/5/11
to cloju...@googlegroups.com
I don't know if this is the kinds of measurements that will help you decide whether it improves startup times, but I AOT compiled a simple hello world program in Clojure and Java, and measured the same kinds of things I did for the other benchmark programs I measured a few weeks ago.  Let me know if you'd like something else measured than what I have, in case I missed the mark.

Across several different JVMs, Clojure 1.3 alpha6 often used about 25% less elapsed time than Clojure 1.3 alpha5, and 15% to 25% less user+system CPU time.  Memory use was 9% to 17% lower, depending on the JVM tested.

More details here:


Click on "Table of hello world results" in the second group of bullets.

Andy

--
You received this message because you are subscribed to the Google Groups "Clojure Dev" group.
To post to this group, send email to cloju...@googlegroups.com.
To unsubscribe from this group, send email to clojure-dev...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/clojure-dev?hl=en.


trptcolin

unread,
Apr 19, 2011, 10:21:04 AM4/19/11
to Clojure Dev
I noticed that this was rolled back this morning. Feel free to ignore
the rest of this if lazy defn loading is actually going away, but
please let me know if I should open a JIRA ticket otherwise.

It appears as though the lazy def loading addition causes a problem in
clojure.test's file/line reporting: if the first use of clojure.test/
is fails, you see something like this:
FAIL in clojure.lang.PersistentList$EmptyList@1 (FnLoaderThunk.java:
31)

Subsequent attempts give the right path / line numbers:
FAIL in clojure.lang.PersistentList$EmptyList@1 (NO_SOURCE_FILE:3)

So, I have a silly workaround for the time being (this is for the
Clojure Koans): to start by calling a test I *know* will pass.

It looks like clojure.test uses the stack trace to report on failures/
errors, so when that additional layer is added (on the first load), we
see FnLoaderThunk as the point of failure. Thoughts?

Thanks!

Colin





On Apr 4, 6:39 am, Rich Hickey <richhic...@gmail.com> wrote:
> I added lazy defn loading as an experiment:
>
> https://github.com/clojure/clojure/commit/71930b6b6537a796cdf13c4ffa7...

Laurent PETIT

unread,
Apr 19, 2011, 11:48:58 AM4/19/11
to cloju...@googlegroups.com
Oh, I intended to do test with a bunch of pre-compiled namespaces in
CCW, but if this has already been rolled back, maybe it's too late ?

2011/4/19 trptcolin <trpt...@gmail.com>:

Reply all
Reply to author
Forward
0 new messages