The JVM Language Summit 2010
olabini.com
olabini.com
The code clears the stack slot for the count method argument. If the object referenced by the argument is not referenced elsewhere, then the object is eligible for gc during the execution of the count method. In the case where the argument is a lazy sequence, this changes the memory requirement from the entire realized sequence to a single item in the sequence.
This trick is employed everywhere in the Clojure implementation where a lazy sequence might be retained. It's not specific to the count function.
... then it means you're completely disconnected from reality?
Edit: Can a down-modder make a convincing argument that a performance benchmark using Fibonacci is even useless, rather than worse than useless by being an appealing lure toward optimizing the wrong things?
Something useful that uses recursion, perhaps. A DFS comes to mind, or countless other common real-world algorithms.
When do you ever care about recursion performance in the context of a function that does nothing but one addition? You might as well compare languages on how well a billion iterations of an empty loop performs.
Your objection is like looking at a floating-point benchmark and thinking, "No real program just crunches doubles. It should include networking code and exception handling."
The point is I don't care about the performance of recursion for its own sake in a context for which there is no serious use. You might, but then you are disconnected from reality, as I said. That isn't an insult, it's just true from the definition.
Doing "benchmarks" with huge functions that do a lot of unrelated things is like "unit testing" a program by running it and seeing if it crashes. It tells you something, but that something is pretty vague.
> I can easily imagine optimizing performance for an unrealistic micro-benchmark that would actually hurt overall recursion performance.
I can't. Can you explain this and give an example?
(This post was made at: 7:05 AM 30th July 2010 Sydney)