-
Notifications
You must be signed in to change notification settings - Fork 378
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ fix #2927 ] Do not eagerly evaluate expressions occurring inside %delay
block
#2939
Conversation
%delay
block%delay
block
cc7557f
to
a7189cf
Compare
Is this related to #2791 ? : ) |
No, not really. Moreover, this PR uses proper memoization instead of relying on #2791, as it yields better performance in this specific case I guess the only way they are related is that both the need for #2791 and discovery of #2927 happened because of an attempt to manipulate large lazily-constructed data structures |
6945720
to
b124ca1
Compare
b124ca1
to
b1bf782
Compare
This makes sense to me however it would be nice to know what the cause |
b1bf782
to
59a9af1
Compare
c77d077
to
07ae9c7
Compare
Seeing that the current CSE is unsound with respect to |
To the best of my knowledge, we have (a) test(s) to verify that non-delayed top-level constants get converted to constants correctly. If these tests still pass (they do), I'm all for merging this. |
07ae9c7
to
7387df6
Compare
I have rebased this PR, all the tests still do pass. Perhaps it's worth re-measuring compilation time as well |
Thanks @stefan-hoeck! I am merging this now and am happy to take the blame if something goes wrong. |
Software's not about blame! Don't feel pressure to mess up something. |
Description
This PR fixes #2927.
Thanks to @stefan-hoeck for his assistance in Discord. He suggested fixing the issue by using Scheme's
delay
andforce
to memoize constants, as in #2807 instead of #2817 that is currently used. However, this solution comes with a performance overhead.To reduce the overhead, I modified CSE to track whether an expression occurs inside a
%delay
block. If that is the case, the expression is lifted as memoized lazy value using Scheme'sdelay
andforce
. Otherwise, it becomes an eagerly evaluated top-level constant. Benchmarking the bootstrapped compiler onidris2api.ipkg
showed 5% slowdown on my machine, which is an improvement compared to the 8.5% slowdown in #2807.Should this change go in the CHANGELOG?
implementation, I have updated
CHANGELOG.md
(and potentially alsoCONTRIBUTORS.md
).