[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simpler srfi 45 implementation
On Tue, 13 Nov 2007, Eli Barzilay wrote:
I was aware of the possible optimization at the time, but didn't find
any example where it mattered. However, if you do put it in:
(let* ((v (force p)))
(if (not (pair? (promise-p prom)))
(set-promise-p! prom (list v)))
(car (promise-p prom)))]
then you do the recursive forcing of `p' in a non-tail conext. My
(vague, not formal at all) feeling about these "referral promises" is
that they do happen in places where the original code had a tail call,
so it might be a bad idea to break it.
The suggested optimization looks very suspicious also to me.
It seems that the non-tail-call could break space-safety.
- Have you run the SRFI-45 tests on your suggested optimization?
Note that this involves uncommenting the mostly nonterminating
test cases, letting them run for some time, keeping track
of the memory consumption with some other tool, and verifying
that it stays bounded. Of course, this is not a substitute
for a theoretical analysis, but it should show pretty quickly
if you are not on the right track.
- Did you find the same slowdown for the first implementation
given in the message
(That one is easier for me to understand and comment on - Eli's
I would have to study again).